使用帮助PHP上传文件时发生未知错误

时间:2019-05-04 10:51:34

标签: php upload

如果上传文件大小为20-22MB,就可以了。上传成功率100%。

但是,如果我尝试上传大小为50MB的文件,则上传过程在17-20-22-24MB(随机)之后停止,没有任何错误,我在Inspect元素->网络-“已传输”中看到了这些MB

cPanel,.php.ini和 phpinfo(); 中的

PHP(5.6)设置相同:

session.gc_maxlifetime = 1440
max_input_time = -1
max_execution_time = -1
upload_max_filesize = 128M
post_max_size = 265M
memory_limit = 2G

HTML:

<!DOCTYPE html>
<html>
<head>
  <title>Upload your files</title>
</head>
<body>
  <form enctype="multipart/form-data" action="upload.php" method="POST">
    <p>Upload your file</p>
    <input type="file" name="uploaded_file"></input><br />
    <input type="submit" value="Upload"></input>
  </form>
</body>
</html>

upload.php:

<?PHP
  if(!empty($_FILES['uploaded_file']))
  {
    $path = "";
    $path = $path . basename( $_FILES['uploaded_file']['name']);
    if(move_uploaded_file($_FILES['uploaded_file']['tmp_name'], $path)) {
      echo "The file ".  basename( $_FILES['uploaded_file']['name']). 
      " has been uploaded";
    } else{
        echo "There was an error uploading the file, please try again!";
    }
  }
?>

如何查看为什么不上传?

1 个答案:

答案 0 :(得分:0)

也许需要增加memory_limit选项?