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

我正在尝试将文件上传到远程主机,但在上传 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


<?php

ini_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 = On

max_execution_time = 300

max_input_time = 300

max_input_vars = 8000

memory_limit = 256M

post_max_size = 192M

session.gc_maxlifetime = 1440

session.save_path = "/var/cpanel/php/sessions/ea-php73"

upload_max_filesize = 256M

zlib.output_compression = Off

托管支持说他们测试了服务器,一切正常。


德玛西亚99
浏览 119回答 1
1回答

呼唤远方

我通过拆分文件并使用blob.slice()分段上传来解决了这个问题
打开App,查看更多内容
随时随地看视频慕课网APP