[eluser]PHP Programmer[/eluser]
I am trying to upload files in two different paths by residing in a single form.
I have two fields - Photo Uplaod (Requires .jpg|.gif|.png ) and Resume Upload (Requires .doc|.rtf)
I am trying following:
View
<?php echo form_open_multipart('upload/do_upload');?>
<input type="file" name="userfile" size="20" />
<input type="file" name="testfile" size="20" />
<br /><br />
<input type="submit" value="upload" />
</form>
Controller
function do_upload()
{
$config['upload_path'] = './uploads/file1/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '100';
$config['max_width'] = '1024';
$config['max_height'] = '768';
$config1['upload_path'] = './uploads/file2/';
$config1['allowed_types'] = 'gif|jpg|png';
$config1['max_size'] = '100';
$config1['max_width'] = '1024';
$config1['max_height'] = '768';
$this->load->library('upload', $config);
$this->load->library('upload', $config1);
$this->upload->initialize($config);
$this->upload->initialize($config1);
if ( ! $this->upload->do_upload())
{
$error = array('error' => $this->upload->display_errors());
$this->load->view('upload_form', $error);
}
else
{
$data = array('upload_data' => $this->upload->data());
$this->load->view('upload_success', $data);
}
}
But it is not uploading the files in both folders (file1 and file2). How can I solve this problem?