I need some help. I want to upload two different files in two different directory by using codeigniter. I wrote the following code in my controller. but it will upload only the first image.
public function save_product() {
$data = array();
$error = array();
$config1['upload_path'] = './manager/images/products/';
$config1['allowed_types'] = 'gif|jpeg|png|jpg';
$config1['max_size'] = '3000000';
$config1['max_width'] = '1024';
$config1['max_height'] = '768';
$this->load->library('upload', $config1);
$config2['upload_path'] = './manager/images/products/large/';
$config2['allowed_types'] = 'gif|jpeg|png|jpg';
$config2['max_size'] = '3000000';
$config2['max_width'] = '1024';
$config2['max_height'] = '768';
$this->load->library('upload', $config2);
if ((!$this->upload->do_upload('product_small_image')) && (!$this->upload->do_upload('product_large_image'))){
$error = array('error' => $this->upload->display_errors());
echo "<pre>";
print_r($error);
exit();
}
else {
$fdata = $this->upload->data();
$data['product_small_image'] = 'manager/images/products/' . $fdata['file_name'];
$data['product_large_image'] = 'manager/images/products/large/' . $fdata['file_name'];
$data['product_id'] = $this->input->post('product_id', TRUE);
$data['product_name'] = $this->input->post('product_name', TRUE);
$data['category'] = $this->input->post('category', TRUE);
$result = $this->super_admin_model->save_product_detail($data);
$sdata = array();
$sdata['message'] = "Well done!</strong> You successfully add the Product Details.";
$this->session->set_userdata($sdata);
redirect('super_admin/add_product', 'refresh');
}
}