PHP File Download - Maximum execution time occurs randomly -


it seems have problem file downloading. logs show error "maximum execution time of 60 seconds exceeded" requested file little css-file 1.64 kb. shouldn't take 60 seconds deliver , unfortunately error not reproducable. if open url works perfectly, errorlog shows errors occuring (randomly?) on other clients several times. there bug in code?

// code from: http://www.richnetapps.com/the-right-way-to-handle-file-downloads-in-php/ // fix ie catching or php bug issue header("pragma: public"); header("expires: -1"); // set expiration time header("cache-control: must-revalidate, post-check=0, pre-check=0"); // browser must download file server instead of cache if(substr($filename, -4) == ".css") {     $mimetype = "text/css"; } header("content-type: ".$mimetype); header("content-length: ".$filesize);  $filehandle = fopen($filename, "rb"); // large file handling: while(!feof($filehandle)) {     print(@fread($filehandle, 1024*8));     ob_flush();     flush();     if(connection_status() != 0)     {         @fclose($filehandle);         unlink($filename);         exit;     } } @fclose($filehandle); unlink($filename); exit; 

the errorline within while-loop, it's not same line.

thanks help! :)

why ob fuss simple css output? sure connection status check causes request hang sometimes.

if(connection_status() != 0)  // 

why need it? can do

header("pragma: public"); header("expires: -1"); // set expiration time header("cache-control: must-revalidate, post-check=0, pre-check=0"); header("content-type: text/css"); header("content-length: ".$filesize); readfile($filename); 

Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -