0
votes

I am encountering a problem with the Codeigniter File Upload class that whenever I try to upload a csv file which is greater than 10MB it says "You did not select a file to upload" but I set already the max size for 20MB and even changed the php.ini file for the upload_max_filesize, memory_limit and the post_max_size but the error is still the same..

Here's the code for the file upload

function upload(){     
    $config = array(
        'upload_path' => './csv_uploads',
        'allowed_types' => 'csv',
        'max_size'  => '20000' // 20MB
    );

    $filename = "csv_file";

    $this->load->library('upload');
    $this->upload->initialize($config);

    if ( ! $this->upload->do_upload($filename))
    {
        $data = array('success' => false, 'error' => $this->upload->display_errors());
        echo json_encode($data);
    }
    else
    {

        $filedata = $this->upload->data();

        $data = array(
            'success' => true,
        );
        echo json_encode($data);    
    }
}

Any help is much appreciated.. Thank you :-)

1
have you set your form enc type to be "multipart"..? and is your file input (in the form) named "csv_file" ..?Sudhir Bastakoti
yes.. this function runs on small files but not for larger than 10MBjily_101
try increasing "max_execution_time" as well...Sudhir Bastakoti
There is also a mast post body size setting for apache that may be limiting the size of the upload.Orangepill
It's ok now.. but my problem is the allowed memory size.. I have already adjusted the memory limit to 512 MB.. how can i solve this?jily_101

1 Answers

0
votes

Thank you guys after searching for some answers.. I managed to do it.. I adjusted the execution time just like @DemoUser said and changed some configurations in php.ini file and restarted my apache and voila it's working now.