douxu0550 2017-05-02 11:41
浏览 72
已采纳

Codeigniter文件上传问题

I have a codeigniter application which basically accepts xls files, parse it and process on the data from the excel file.

Here is the code that I used for uploading the file.

When the form is submitted, the code below is executed. When I submit a file with small size, it is uploaded properly and is also processed. However, if I upload a file with a larger size, it gets uploaded, but isnt processed. I even get redirected to the upload form with the error "You did not select a file to upload."

Is this something which is caused by max_execution_time? PS: I have these three lines at the top of the controller

set_time_limit(0);
ini_set('memory_limit', '20000M');
ini_set('max_execution_time', 3000);

UPDATE : The file size I am trying to update is of 1.59 MB

Upload

public function do_upload() {
     $config['upload_path']   = './excel_files/';
     $config['allowed_types'] = 'xls|xlsx';
     $config['max_size']      = 100000;

     $this->load->library('upload', $config);
    //  upload failed, handle properly
     if ( ! $this->upload->do_upload('userfile')) {
        $error = array('error' => $this->upload->display_errors());
        $data = array('subview'=>'admin/upload_form','error'=>$error);
        $this->load->view('layout', $data);
     }

    //  upload success, record the file data
     else {
       $uploadData = $this->upload->data();

       $fileData = array(
                      'name'    =>  $uploadData['orig_name'],
                      'size'    =>  $uploadData['file_size'],
                      'stored_name' =>  $uploadData['file_name'],
       );

       $this->file_m->insert($fileData);

        $this->process($uploadData); // process the uploaded  file
     }
  }
  • 写回答

2条回答 默认 最新

  • doupa1883 2017-05-02 19:36
    关注

    It looks overriding code is not working.

    set_time_limit(0);
    ini_set('memory_limit', '20000M');
    ini_set('max_execution_time', 3000);
    

    Way 1:

    Update the settings in php.ini file. Hope issue will be resolved.

    max_execution_time = 259200
    max_input_time = 259200
    memory_limit = 300M
    upload_max_filesize = 200M
    post_max_size = 200M
    

    Way 2:

    .htaccess way

    <IfModule mod_php5.c>
       php_value post_max_size 200M
       php_value upload_max_filesize 200M
       php_value memory_limit 300M
       php_value max_execution_time 259200
       php_value max_input_time 259200
       php_value session.gc_maxlifetime 1200
    </IfModule>
    

    verify the settings by creating a php info file. test_settings.php

    <?php
        phpinfo();
    ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!