我正在尝试将大文件上传到我的服务器(我的服务器支持 post_max_size
192mb 和 max_execution_time
600 秒).当我上传 100mb 文件时,执行将在 600 秒后停止,因此文件不会上传到服务器.如何在 PHP 中增加 max_execution_time
(仅用于文件上传过程)?我试过了:
I'm trying to upload large files to my server (my server support post_max_size
192mb and max_execution_time
600 sec). When I upload 100mb files execution will stop after 600 sec so files are not uploaded to the server. How can I increase max_execution_time
in PHP (only for the file uploading process)? I have tried:
ini_set ( 'max_execution_time', 1200);
if(move_uploaded_file($_FILES['Video']['tmp_name'],$tmppath)) {
// ...
}
有什么想法可以克服这个问题吗?
Any ideas how I can overcome this?
将此添加到 htaccess 文件中(并查看下面添加的编辑注释):
Add this to an htaccess file (and see edit notes added below):
<IfModule mod_php5.c>
php_value post_max_size 200M
php_value upload_max_filesize 200M
php_value memory_limit 300M
php_value max_execution_time 259200
php_value max_input_time 259200
php_value session.gc_maxlifetime 1200
</IfModule>
其他资源和信息:
https://www.php.net/manual/en/info.configuration.php
https://www.looklinux.com/how-to-set-php-maximum-execution-time-in-an-htaccess-file/
2021 年
随着 PHP 和 Apache 的发展和壮大,我认为花点时间提及一些需要考虑的事情和可能的陷阱"对我来说很重要.考虑:
As PHP and Apache evolve and grow, I think it is important for me to take a moment to mention a few things to consider and possible "gotchas" to consider:
中的特定模块,作为模块运行(更安全的选项)将触发要使用的设置.
mod_php5.c
.如果您使用的是 PHP 7,则将其替换为 mod_php7.c
.php.ini
配置文件中定义.此方法通常仅在您的托管服务提供商不授予您更改这些文件的权限时才有用.在您可以编辑 PHP 配置的情况下,建议您在那里应用这些设置.<IfModule
is loaded.mod_php5.c
in the first line. If you are using PHP 7, you would replace that with mod_php7.c
.php.ini
config file(s). This method is usually only useful in the event your hosting provider does not give you access to change those files. In circumstances where you can edit the PHP configuration, it is recommended that you apply these settings there.这篇关于在 PHP 中增加 max_execution_time ?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!