为了账号安全,请及时绑定邮箱和手机立即绑定

60 秒后上传文件时出现错误请求 400

60 秒后上传文件时出现错误请求 400

PHP
德玛西亚99 2023-06-18 16:27:11
我正在尝试将文件上传到远程主机,但在上传 60 秒后收到 400 错误请求,我不知道这是会话问题还是防火墙问题。该代码在我的本地主机和其他服务器上运行良好<!DOCTYPE html><html><body>    <form action="upload.php" method="post" enctype="multipart/form-data">    Select file to upload:    <input type="file" name="fileToUpload" id="fileToUpload">    <input type="submit" value="Upload file" name="submit">    </form></body></html>// upload.php file<?phpini_set('max_execution_time', 300);ini_set('display_errors', 1);ini_set('display_startup_errors', 1);error_reporting(E_ALL);?><?php$target_dir = "docs/";$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);$uploadOk = 1;if(isset($_POST["submit"])) {    if (file_exists($target_file)) {        echo "Sorry, file already exists.";        $uploadOk = 0;    }          if ($uploadOk == 0) {        echo "Sorry, your file was not uploaded.";    } else {    // if condition to check if the file has been uploaded or not        if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {          echo "The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded.";        }else {          echo "Upload failed";        }      }}?>php.ini文件内容:display_errors = Onmax_execution_time = 300max_input_time = 300max_input_vars = 8000memory_limit = 256Mpost_max_size = 192Msession.gc_maxlifetime = 1440session.save_path = "/var/cpanel/php/sessions/ea-php73"upload_max_filesize = 256Mzlib.output_compression = Off托管支持说他们测试了服务器,一切正常。
查看完整描述

1 回答

?
呼唤远方

TA贡献1856条经验 获得超11个赞

我通过拆分文件并使用blob.slice()分段上传来解决了这个问题


查看完整回答
反对 回复 2023-06-18
  • 1 回答
  • 0 关注
  • 112 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信