繁体   English   中英

CodeIgniter上传大文件

[英]CodeIgniter Uploading Large Files

我已经设置了codeigniter来上传小于2MB的小文件,并且工作正常。 但我无法上传大型文件20MB>

   function stage1()
    {
    ini_set('upload_max_filesize', '200M');
    ini_set('post_max_size', '200M');                               
    ini_set('max_input_time', 3000);                                
    ini_set('max_execution_time', 3000);

    $config['upload_path'] = './temp/';
    $config['allowed_types'] = 'zip';

    $this->load->library('upload', $config);
    $this->upload->initialize($config);                             
    if(!$this->upload->do_upload('userfile'))                       
    {
      $error = array('error' => $this->upload->display_errors());   
      $this->load->view('upload_form', $error);                     
    }
    else
    {
      $data = array('upload_data' => $this->upload->data());        
      //do stuff
    }
  } 

我不确定上面的代码有什么问题。 我重写php.ini接受更大的文件,并花更多的时间执行脚本,但它仍然返回相同的错误:

You did not select a file to upload.

同样,这适用于小文件但不适用于大文件。

编辑:原来我的服务器提供商有限的文件上传,所以除了FTP文件之外没有解决方案。

下面的代码用在你的php文件中。

ini_set( 'memory_limit', '200M' );
ini_set('upload_max_filesize', '200M');  
ini_set('post_max_size', '200M');  
ini_set('max_input_time', 3600);  
ini_set('max_execution_time', 3600);

在.htaccess文件中设置以下代码

php_value upload_max_filesize 128M  
php_value post_max_size 128M  
php_value max_input_time 3600  
php_value max_execution_time 3600

评论后编辑我的答案

更新答案

在stage1函数中设置config参数。

$config['max_size'] = '1000000';
$config['max_width']  = '1024000';
$config['max_height']  = '768000';

然后尝试一下。

我不确定您的服务器是否接受使用hphp脚本修改的ini“upload_max_filesize”属性。 默认情况下,它不能根据文档http://php.net/manual/fr/ini.core.php

upload_max_filesize | “2M”| PHP_INI_PERDIR | PHP_INI_ALL倒PHP <= 4.2.3。

PHP_INI_PERDIR表示必须直接在您的ini文件中写入。 如果你对php.ini没有控制权,你将无法覆盖此属性。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM