0

I use this function http://us.php.net/manual/en/function.filesize.php#115792 to get file/folder size over 2 GB on 32bit/64bit platforms.

function my_filesize($fp) {...}

$dir = opendir( 'my_path' );
print my_filesize($dir);

function my_filesize($fp) - see link above.

But I get Fatal error: Maximum execution time of 30 seconds exceeded in C:\... on line *

This is line:

if (0 === fseek($fp, - $step, SEEK_CUR)) {

I try use set_time_limit(0). Of course it doesn't work.

If I use http://us.php.net/manual/en/function.filesize.php#113457 I get the same.

What do I do?

EDIT 2: It's seem I need use not opendir. I must use fopen and path must contain file, not directory.

  • 1
    Have a look at [this SO question](http://stackoverflow.com/questions/11999678/php-timeout-set-time-limit0-dont-work). There are multiple reasons you could not be allowed to remove the time limit. There are also multiple ways to _attempt_ working around it. – Crackertastic Oct 21 '14 at 11:37
  • It's seem I need use not opendir. I must use **fopen** and path must contain file, not directory. – user3679891 Oct 21 '14 at 12:35

1 Answers1

0

Use

set_time_limit — Limits the maximum execution time

Set the number of seconds a script is allowed to run. If this is reached, the script returns a fatal error. The default limit is 30 seconds or, if it exists, the max_execution_time value defined in the php.ini.

When called, set_time_limit() restarts the timeout counter from zero. In other words, if the timeout is the default 30 seconds, and 25 seconds into script execution a call such as set_time_limit(20) is made, the script will run for a total of 45 seconds before timing out.

Harutyun Abgaryan
  • 2,013
  • 1
  • 12
  • 15