【问题标题】:PHP - Error 3 showing while uploading file greater than 64kbPHP - 上传大于 64kb 的文件时显示错误 3
【发布时间】:2020-03-23 21:58:02
【问题描述】:

我正在尝试上传一个大小为 91kb 的文件“profile-cover.png”。因此该文件得到错误代码 3,因为它不小于 64 kb。我在 php.ini 中的设置是:

upload_max_filesize = 10M
post_max_size = 10M

所以我认为设置没有错误。错误打印如下:

([upload] => Array
    (
        [name] => Array
            (
                [0] => profile-cover.png
            )

        [type] => Array
            (
                [0] => 
            )

        [tmp_name] => Array
            (
                [0] => 
            )

        [error] => Array
            (
                [0] => 3
            )

        [size] => Array
            (
                [0] => 0
            )

    )
)

这是我的代码:

$title = mysqli_real_escape_string($con, $title);
$des = mysqli_real_escape_string($con, $des);
$file_count = count($_FILES['upload']['name']);
for($i=0;$i<$file_count;$i++){
     $extensions = array('jpg','png','gif','jpeg');
     $file_ext = explode('.',$_FILES['upload']['name'][$i]);
     $file_ext = strtolower(end($file_ext));

     if(in_array($file_ext,$extensions)){
        $newFile = 'uploads/'.$name=$userId.'_'.date('m-d-Y_his').'.'.$file_ext;
     if(move_uploaded_file ( $_FILES['upload']['tmp_name'][$i], $newFile)) 
      {
         $date = date('Y-m-d H:i:s');
         $sql = "INSERT INTO picture (Album_Id,FileName,Title,Description,Date_Added) VALUES ('$albumId','$newFile','$title','$des','$date')";
         if(mysqli_query($con, $sql)){
              $insertErr = "Image uploaded successfully.";
         }else{
              $insertErr = "There was an error while uploading the images.";
         }
      }
   }else{
          $uploadErr = "'".$_FILES['upload']['name'][$i]."' unsupported extension";
   }
}

有人可以帮忙吗?

【问题讨论】:

标签: php file-upload


【解决方案1】:

PHP - 错误 3 原因:

1.权限不存在。

2.服务器空间问题。

3.可能是上传时出错

【讨论】:

  • 1.我已经完全控制了上传文件夹。 2.有足够的空间上传91kb的文件 3.每次上传大于64kb的文件都会报错
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-06-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-04-06
  • 2017-02-27
相关资源
最近更新 更多