I was trying to upload several files together with CI framework. what I want is upload files to different folders. Therefore, I tried check file input element's name and set fill path.
Here is the code to get clear idea about my problem.
$config['allowed_types'] = 'jpg|doc|pdf|docx';
//$config['max_size'] = '100';
//$config['max_width'] = '1024';
//$config['max_height'] = '768';
if($this->input->post('bankbook_attachment')){
echo 'bank'.$this->input->post('bankbook_attachment');
$config['upload_path'] = './uploads/bank/';
$fillselect='bankbook_attachment';
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload($fillselect))
{
$error = array('error' => $this->upload->display_errors());
echo 'error'.print_r($error);
}
else
{
// $data = array('upload_data' => $this->upload->data());
// print_r($data);
$datame=$this->upload->data();
$fillnamebank= $datame['file_name'];
echo 'fillname is'.$fillnamebank;
// $this->load->view('upload_success', $data);
}
}
if($this->input->post('emp_nic_attachment')){
$config['upload_path'] = './uploads/nic/';
$fillselect='emp_nic_attachment';
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload($fillselect))
{
$error = array('error' => $this->upload->display_errors());
echo 'error'.print_r($error);
}
else
{
// $data = array('upload_data' => $this->upload->data());
// print_r($data);
$datame=$this->upload->data();
$fillnamenic= $datame['file_name'];
echo 'fillname is'.$fillnamenic;
// $this->load->view('upload_success', $data);
}
}
but when I run the code I notice that it doesn't validate if conditions, it leaves them. In CI examples I have notice that they don't use post array to get the name but directly hard code. But which is impossible in my application.
How to solve this. I think simply problem is in this line $this->input->post('emp_nic_attachment')