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条)

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器