I’ve made a VERY basic website which takes an array of image URLs, zips them, and returns the zip location. The problem is that the script cuts off at some point.
One of the following usually happens:
- not all the pictures are copied
- not all pictures are copied and the last picture has 0 file size
- sometimes the ajax call doesn’t run the error or success callback
Is this because the server is only allowing a certain amount of time for the script to execute? It does seem to work with less pictures. What can I do?
I have the following settings:
- max_execution_time 10
- max_file_uploads 20
- max_input_nesting_level 64
- max_input_time 10
also, set_time_limit is disabled.
I tried ini_set(‘max_execution_time’, 300); and nothing changed
edit: Probably a REALLY stupid question, but would it change anything if I executed another PHP page after a certain amount of time if the script isn’t going to finish before the limit?
I’m using:
<?php
include('zip2.php');
header("content-type: text/javascript");
function err($que){
$obj->err = $que;
echo $_GET['callback']. '(' . json_encode($obj) . ');';
die;
}
if(!count($_GET['pictures'])>0){die;}
$tmpp = tempnam('userzips','mod');
unlink($tmpp);
$loc = 'userzips/'.basename($tmpp);
mkdir($loc);
$a=$_GET['pictures'];
for($i=0;$i<count($a);$i++){
copy($a[$i],$loc.'/'.basename($a[$i])) or err("didn't zip");
}
Zip($loc,$loc.'/pictures.zip') or err("didn't zip");
$obj->loc = 'http://mysite.com/'.$loc.'/pictures.zip';
$obj->allgood = true;
echo $_GET['callback']. '(' . json_encode($obj) . ');';
?>
IT WILL SOMETIMES work and sometimes not for the same input. This is what really gets me.
upload_max_filesize and post_max_size also can be reason
try to check errors while copy
also I heard that there are some problems with copy when url have spaces