Welcome Guest, Not a member yet? Register   Sign In
When uploading 2 flv file using the file uploading class does not work
#1

[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
#2

[eluser]pistolPete[/eluser]
It's possible that post_max_size (which is set in php.ini) is exceeded if you upload two flv files; try raising that value.
#3

[eluser]BrianDHall[/eluser]
Another thing is if nothing at all shows up in $_FILES then it can't be purely a CI issue, because it doesn't do anything to $_FILES - that gets filled before any script is called. You might check into your HTML for the actual form upload - if there is a problem there the files wouldn't be posted correctly, perhaps.
#4

[eluser]Unknown[/eluser]
it now works!!!!!!!!!!!!!!!!!!!!!!

Need only to change the "post_max_size". Previously, I only changed the "upload_max_filesize". This only shows hoe noob I am at PHP. :lol:
Thank you very much to everyone that helped.




Theme © iAndrew 2016 - Forum software by © MyBB