gpt4 book ai didi

PHP 文件上传是否受 max_input_time 影响?

转载 作者:IT王子 更新时间:2023-10-29 01:10:35 26 4
gpt4 key购买 nike

我正在研究在 PHP 中设置默认值的最佳值是什么。我见过很多关于 max_input_time 的矛盾点。

这个回答说他认为文件上传不计入计时器: https://stackoverflow.com/a/3758522/518169

在PHP官方文档中,有一个巨大的红色警告:

max_input_time sets the maximum time, in seconds, the script is allowed to receive input; this includes file uploads. For large or multiple files, or users on slower connections, the default of 60 seconds may be exceeded

来源:http://php.net/manual/en/features.file-upload.common-pitfalls.php , 最后更新:2012 年 7 月 6 日星期五

因此,从这里看来 max_input_time 确实会影响 文件上传,并确保访问者可以上传 20 MB 的文件,即使是从慢速或移动连接,默认值60的绝对不够!

您建议将此值设置为什么? 300?

还有,max_execution_timemax_input_time有什么关系吗?例如 max_execution_time 需要大于 max_input_time 吗?

最佳答案

经过一些快速基准测试我认为 max_input_time 对处理连接速度较慢的用户的大量上传没有任何影响。

来自 http://us3.php.net/manual/en/info.configuration.php#ini.max-input-time

This sets the maximum time in seconds a script is allowed to parse input data, like POST and GET. It is measured from the moment of receiving all data on the server to the start of script execution.

我使用的是 PHP 5.3.8 并使用了以下 .htaccess 配置

php_value max_input_time 5
php_value max_execution_time 1
php_value upload_max_filesize "2048M"
php_value post_max_size "2048M"

我的测试脚本是:

<?php
if (!empty($_FILES)) {
echo '<pre>';
var_dump($_FILES);
echo '</pre>';
}
?>
<form enctype="multipart/form-data" method="POST">
File: <input name="userfile" type="file" />
<input type="submit" value="Upload" />
</form>

经过多次试验,我的 1.5G 文件大约需要 16-17 秒上传4-5 秒处理,执行时间基本上为 0。

max_input_time 5 脚本完成。将其设置为 4 我们得到 PHP Fatal error: Maximum execution time of 4 seconds exceeded in Unknown on line 0, referer: http://localhost/test-upload.php

似乎 max_execution_time 也没有任何影响,因为我们在整个测试过程中都将它保持在 1。

关于PHP 文件上传是否受 max_input_time 影响?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11387113/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com