This is a discussion on Download via PHP problem within the PHP Language forums, part of the PHP Programming Forums category; Hello, I'm using a script to handle downloads of files, it seems to work but I'm getting random ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hello,
I'm using a script to handle downloads of files, it seems to work but I'm getting random server errors. I guess it has something to do with the filesize. The script will be needed to download files of 6 to 8 MB but I've only tested with files from 0.5 to 2.5 MB. I get the following error: The server closed the connection while reading the response. Contact your system administrator. (SERVER_RESPONSE_CLOSE) All help is greatly apreciated! B. <?php //... //Download part of the script: $zipfile="/path/to/the/zipfiles/".$_POST['orderid'].".zip"; if (empty($zipfile) || !file_exists($zipfile)) { header("HTTP/1.1 404 Not Found"); header("Status 404"); Header("Location:icouldnotfindthatfile"); } else { $filesize=filesize($zipfile); $name= $_POST['orderid'].".zip"; $mime='application/x-zip'; //hack for bloody ie5.5 if(preg_match("/MSIE 5.5/", $HTTP_USER_AGENT)) {header("Content-Disposition: filename=$name");} //other browsers else {header("Content-Disposition: attachment; filename=$name");} header("Content-Type: $mime"); header("Content-Length: $filesize"); header ("Content-Transfer-Encoding: binary"); $fh = fopen($zipfile, "r"); fpassthru($fh); } ?> |
|
|||
|
Hi Bert,
may be you have to increase the maximum execution time of your script, see [1]. Greetings from Frankfurt / Germany, Fabian Wleklinski [1] http://www.php.net/function.set-time-limit |