开发者

PHP randomly cuts off

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 ano开发者_如何学Gother 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

upload_max_filesize=100M
post_max_size=105M
max_execution_time=600
max_input_time=600

try to check errors while copy

if(!@copy('http://someserver.com/somefile.zip','./somefile.zip'))
{
    $errors= error_get_last();
    echo "COPY ERROR: ".$errors['type'];
    echo "<br />\n".$errors['message'];
} else {
    echo "File copied from remote!";
}

also I heard that there are some problems with copy when url have spaces

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜