我想上传大型 Excel 文件。但由于文件包含很多行,因此加载速度很慢,并且出现此错误:
Controller.php 第 457 行出现 FatalErrorException:超出最大执行时间 120 秒
我已经把它放在我的 .htaccess 上:
<IfModule mod_php5.c>
php_value max_execution_time 1500
php_value upload_max_filesize 15M
</IfModule>
我还将其添加到控制器的顶部:
ini_set('memory_limit', '3000M');
ini_set('max_execution_time', '0');
我还更改了 php.ini 中的 max_execution_time:
max_execution_time = 300
并在 config.inc.php 上添加此内容:
$cfg['ExecTimeLimit'] = 0;
我想知道为什么它根本不起作用并不断让我陷入该错误......代码是否有遗漏?任何帮助将不胜感激,谢谢!
要临时设置限制,您可以在代码中执行此操作
ini_set('max_execution_time', 300); //300 seconds = 5 minutes
或
set_time_limit(300);
要永久更改,请更改
php.ini
中的以下值
max_execution_time = 360 ; Maximum execution time of each script, in seconds (I CHANGED THIS VALUE)
max_input_time = 120 ; Maximum amount of time each script may spend parsing request data
memory_limit = 128M ; Maximum amount of memory a script may consume (128MB by default)
编辑php.ini:
php.ini路径:
/etc/[your php version example:php5]/apache2/php.ini
max_execution_time = 360 ; Maximum execution time of each script, in seconds (I CHANGED THIS VALUE)
max_input_time = 120 ; Maximum amount of time each script may spend parsing request data
memory_limit = 128M ; Maximum amount of memory a script may consume (128MB by default)
我希望这可以帮助你。
尝试在查询之前将其添加到控制器中
set_time_limit(300);
解决方案 转到 InteractsWithFlashData 特征并编写一行代码来设置执行时间限制。 InteractsWithFlashData路径: 供应商/laravel/framework/src/http/Concerns/InteractsWithFlashData.php 并添加 set_time_limit(0);
请点击此链接获取更多解决方案, [1]:https://www.vaidikalaya.com/laravel-how-to-increase-maximum-execution-time