4

I want to upload large excel file. But because the file contains many rows, the loading is so slow and I got this error:

FatalErrorException in Controller.php line 457: Maximum execution time of 120 seconds exceeded

I already put this on my .htaccess:

<IfModule mod_php5.c>
    php_value max_execution_time 1500
    php_value upload_max_filesize 15M
</IfModule>

I also add this at the top of the controller:

ini_set('memory_limit', '3000M');
ini_set('max_execution_time', '0');

I also change max_execution_time at the php.ini:

max_execution_time = 300

And also add this on config.inc.php:

$cfg['ExecTimeLimit'] = 0;

I wonder why it's not work at all and keep getting me into that error... Is there a miss at the code? Any help would be appreciate, Thanks!

Nadeshiko Rin
  • 87
  • 1
  • 2
  • 13
  • Check the php.ini from your apache/bin folder – Walter Cejas Dec 18 '18 at 03:16
  • 1
    It would be lovely if you did some research before posting a question that has _multiple_ duplicates already on SO: https://stackoverflow.com/questions/5164930/fatal-error-maximum-execution-time-of-30-seconds-exceeded – random_user_name Dec 18 '18 at 03:18

3 Answers3

11

To temporarily set the limit, You can just do this in the code

ini_set('max_execution_time', 300); //300 seconds = 5 minutes

or

set_time_limit(300);

To change permanently, change the following values in 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)
Benjamin Gakami
  • 1,610
  • 2
  • 16
  • 22
5

Edit php.ini:

php.ini path : /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)

I hope this could help you.

NIKUNJ PATEL
  • 2,034
  • 1
  • 7
  • 22
Mayur Panchal
  • 659
  • 6
  • 25
1

try to add this in your controller before the query

set_time_limit(300);

Kapitan Teemo
  • 2,144
  • 1
  • 11
  • 25