[eluser]Unknown[/eluser]
I am trying to create a page that uploads multiple files (combinations of images(jpg,gif,png) and videos (flv)). it works fine if there is only one video file in the list of files to be uploaded even if multiple images are also part of the list. if it is 2 or more video files, all the files disappear from the $FILES array and even the other values I passed went missing, it is as if I did not pass anything. I do not know what is wrong. I am new to CI and the MVC architecture.
Here is my code in the do_upload():
the file inputs are named "userfile_0", "userfile_1" and so on...
Code:
function do_upload()
{
$projID = $this->input->post('proj');
is_dir('./Files/proj_.$projID.'files')?"":mkdir('./Files/proj_'.$projID.'files', 0777);
//Configure the upload
$config['upload_path'] = './Files/proj_.$projID.'files';
$config['allowed_types'] = 'flv|gif|jpg|png|jpeg';
$config['max_size'] = '0';
$config['remove_spaces']= TRUE;
$config['encrypt_name'] = TRUE;
$this->load->library('upload', $config);
$i=0; //File Counter
$j=0; //Error counter
$k=0; // OK counter
$errorFiles=array();;
$uploadedFiles=array();
$PageData = $this->getPageData();
while(isset($_FILES["userfile_".$i])){
if ( ! $this->upload->do_upload("userfile_".$i))
{
$errorFiles[$j] = array("filename" => $_FILES["userfile_".$i]["name"],
"error" => $this->upload->display_errors("<span>","</span>"));
$j++;
}
else
{
$uploadedFiles[$k] = $this->upload->data();
$k++;
}
$i++;
}
$PageData["FileErrors"] = $errorFiles;
$PageData["OKFiles"] = $uploadedFiles;
$PageData["projFolder"] = "proj_".$projID."files";
$this->load->view('adminPages/attachCaption_view', $PageData);
}
please help. Thanks in advance