I am using centOS 5 server. i got the error while i was attempting to download 1GB of file from server to my server that
maximum execution time exceeded.
i opened my php.ini file, it was written there
max_execution_time = 30 ; Maximum execution time of each script, in seconds
max_input_time = 60 ; Maximum amount of time each script may spend parsing request data
memory_limit = 128M ; Maximum amount of memory a script may consume
in last line it is written Maximum amount of memory a script may consume so what does it mean actually? it will not download more than this per script execution or its about the memory taken by script to be executed (sharing types)
i searched but not got the answer of this. Please if any one can tell me what it mean exactly and how can i be able to download approx 1GB of data through script from other server using PHP.
EDIT
code i am using to download the file from server using curl
$username = "user";
$password = "pwd";
$url = "http://domain.com/feeds/";
global $ch;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml"));
curl_setopt($ch, CURLOPT_UNRESTRICTED_AUTH, 1);
$output = curl_exec($ch);
$r = time()-(24*60*60);
$dateit = date("Ymd", $r);
$file8 = "abc".$dateit.".tbz";
$file3 = "abc".$dateit.".tbz.md5";
$file5 = "xyz".$dateit.".tbz";
$file4 = "xyz".$dateit.".tbz.md5";
$file7 = "lmn".$dateit.".tbz";
$file2 = "lmn".$dateit.".tbz.md5";
$file6 = "pqr".$dateit.".tbz";
$file1 = "pqr".$dateit.".tbz.md5";
$arr = array($file1, $file2, $file3, $file4, $file5, $file6);
for($i=0;$i<=4;$i++)
{
$url = "http://domain.com/feeds/current-data/".$arr[$i];
curl_setopt($ch, CURLOPT_URL, $url);
$fp = fopen("adminArea/folder1/".$arr[$i], 'w+');
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_exec ($ch);
}
fclose($fp);
curl_close($ch);
Any idea help link or view will be highly appreciated.
The
memory_limitis the max amount of data the script can have loaded into memory at any given time. That means that if you try and read the entire contents of a 1GB file into a variable, yes, you’ll run into problems.On the other hand, if you download the file directly to disk (rather than trying to read its contents in your script), it can be streamed through memory piece by piece, and thus you wouldn’t necessarily run into memory limitations.
You could also manually read the file chunk by chunk using things like
fread()to keep from going over the memory limit at any given time.