【问题标题】:Empty FILES array for large (ish) file uploads大(ish)文件上传的空文件数组
【发布时间】:2014-08-22 07:29:07
【问题描述】:

我有一些遗留代码,在我的一生中我无法理解为什么它突然停止工作。

非常基本的上传脚本:

if($_FILES['csvfile']['name']){
    //if no errors...
    if(!$_FILES['csvfile']['error']){
        //now is the time to modify the future fle name and validate the file
        $new_file_name = strtolower($_FILES['csvfile']['tmp_name']); //rename file


       //move it to where we want it to be
       move_uploaded_file($_FILES['csvfile']['tmp_name'], 'active_leads1.csv');
       //echo 'Congratulations!  Your file was accepted.';

    }else{
      //set that to be the returned message
      //echo 'Ooops!  Your upload triggered the following error:  '.$_FILES['csvfile']['error'];

       die("Unfortuanatly there was an error: {$_FILES['csvfile']['error']}");
   }
}else{
    die("Unfortuanatly there was an error: ".print_r($_FILES,true)."");

}

同样的形式也一样基本:

<form action="csvconvert.php" method="post" enctype="multipart/form-data">
 <input type="file" name="csvfile" size="25" />
 <input type="submit" name="submit" value="Submit" />
</form>

然而,它在文件 c 上失败了。 11MB。较小的文件是可以的。

检查了发布限制和上传限制,两者都很好(256M 和 128M),最大输入时间是 240,但是如果我 print_r $_POST 和 $_FILES 它们都是空的。

以前有人遇到过这种情况吗?任何帮助将不胜感激!

【问题讨论】:

  • 你有什么错误?代码是否回退到您的错误消息之一?
  • 检查使用 if(isset($_POST)) { print_r($_FILES); },如果你正在获取文件
  • 嗨,正如我的帖子中提到的,$_POST 和 $_FILES 上的 print_r 返回一个空数组,所以我也没有收到提交按钮。

标签: php file-upload upload


【解决方案1】:

如果较小的文件没问题,您确定您的upload_max_filesize 大于 11MB 吗?使用echo phpinfo();upload_max_filesize的值是多少。

【讨论】:

  • 感谢您的回答,但正如我的帖子中所述,upload_max_filesize 设置为 128MB,post_max_size 设置为 256MB
  • 这很奇怪。那么我唯一能想到的可能是max_input_time 的值太小了。这有什么价值?
  • 240,上传大约需要一分钟 - 这也是我难过的原因!
猜你喜欢
  • 2020-12-08
  • 1970-01-01
  • 2015-01-01
  • 2014-05-29
  • 1970-01-01
  • 1970-01-01
  • 2012-03-22
  • 2020-10-20
  • 1970-01-01
相关资源
最近更新 更多