[eluser]tjstalcup[/eluser]
I wish there was such a thing as a CI consultant that I could pay for help
I am new to CI, and i'm trying to do a simple image upload however I keep getting the error
You did not select a file to upload.
here is my code:
controller:
Code:
function create_imprint()
{
$config['upload_path'] = './uploads/';
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload())
{
$data['error'] = array('error' => $this->upload->display_errors());
$product_id = $this->uri->segment(3);
$this->load->model('Imprint');
$this->db->where('id',$product_id);
$query = $this->db->get('products');
$row = $query->row();
$data['title'] = "NAVA New $row->name";
$data['productname'] = $row->name;
$data['query'] = $this->Imprint->get_fields($product_id);
$this->load->view('header',$data);
$this->load->view('products/new_imprint_view',$data);
}
else
{
$data = array('upload_data' => $this->upload->data());
$this->load->model('Imprint');
//$query = $this->Imprint->new_data($_POST);
$data['title'] = "NAVA New Brochure";
$this->load->view('header', $data);
$this->load->view('products/create_imprint_view',$data);
}
}
view
Code:
<h2>New <?=$productname?></h2>
<p><b><?=$error['error']?></b></p>
<p><?=anchor('products/imprint/'.$this->uri->segment(3),'Back to '.$productname.' Data List');?></p>
<?=form_open_multipart('products/create_imprint/'.$this->uri->segment(3));?>
<table border="0" cellpadding="5" cellspacing="5">
<?php foreach($query->result() as $row): ?>
<tr>
<td align="right" valign="top"><label for="<?=$row->name?>" title="<?=$row->tooltip?>"><?=$row->label?>:</label></td>
<?php if($row->type=="textarea"): ?>
<td><textarea rows="20" cols="40" name="<?=$row->name?>" id="<?=$row->name?>" title="<?=$row->tooltip?>"></textarea></td>
<?php elseif($row->type=="image"): ?>
<td><input type="file" name="<?=$row->name?>" id="<?=$row->name?>" title="<?=$row->tooltip?>" size="20" /></td>
<?php endif; ?>
</tr>
<?php endforeach; ?>
<tr>
<td> </td>
<td><input type="submit" value="Create Artwork" /></td>
</tr>
</table>
</form>