[eluser]mikka23[/eluser]
I have a form with two file inputs to upload images. My problem is uploading the second one. How do I upload two images and also retrieve the info for each upload separately (filename etc.)? All help is appreciated. At the moment only the first image is uploaded. The filepath for the first image is also shown where I expected the second file path to be.
In my controller:
Code:
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '10000';
$config['max_width'] = '1024';
$config['max_height'] = '768';
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload())
{
$error = array('error' => $this->upload->display_errors());
$this->load->view('addpageerror', $error);
}
else
{
$uploadimg = $this->upload->data('userfile');
$uploadthumb = $this->upload->data('thumbnail');
$date = date("Y-m-d");
$this->ptitle = $_POST['ptitle'];
$this->pabout = $_POST['pabout'];
$this->fullscr = $uploadimg['full_path'];/// First image path
$this->thumbnail = $uploadthumb['full_path']; /// Second Image Path
$this->url = $_POST['url'];
$this->date = $date;
$this->db->insert('portfolio',$this);
$data = array('upload_data' => $this->upload->data());
}
Form:
Code:
<h2>Add New Work</h2>
<?php echo form_open_multipart('admin/portfolio/addwork'); ?>
<h4>Project Title</h4>
<input type="text" name="ptitle" value="" size="50" />
<h4>About Project</h4>
<?
$data = array(
'name' => 'pabout',
'id' => 'pabout',
'value' => '',
'rows' => '15',
'cols' => '80',
'style' => 'width:100%',
);
echo form_textarea($data);
?>
<h4>Services Used</h4>
<?php
foreach($skillset->result() as $bow){
echo form_checkbox('skill[]', $bow->id, FALSE);
echo "$bow->value";
}
?>
<h4>URL of Demo</h4>
<input name="url" value="http://" type="text" />
<h4>Full Screenshot of Design</h4>
<p>Dimensions - 1024x768</p>
<p><input name="userfile" type="file" /></p>
<h4>Small Thumbshot of Design</h4>
<p>Dimension - 174x103 </p>
<p><input name="thumbnail" type="file" /></p>
<p><input type="submit" value="Submit" /></p>
</form>