Image

Imageswitchstatement wrote in Imagephp

sending a zip file to

i'm trying to dynamically create zip files and then send them to the browser. all of the file downloads are cutting off somewhere between 12.1 and 12.5mb. i think it has something to do with the headers i'm writing, because if i create a direct link to a zip file after it's created, the download is successful and the file is complete/functional. the zip files being created can also be downloaded via ftp and opened successfully.

in my script i'm doing:

----
header("Content-Type: application/octet-stream"); //i've also tried application/zip
header("Connection: keep-alive");
header("Accept-Ranges: bytes");
header("Cache-Control: public, must-revalidate");
header("Content-Length: ".(string)(filesize($file)));
header('Content-Disposition: attachment; filename="'.get_theme_name($theme).'.zip"');
header("Content-Transfer-Encoding: binary\n");

ob_end_clean();
readfile($file);
----

there's nothing else in the script except a function to connect to the database and a function to create the zip file. nothing is output to the browser, and the zip file is created successfully.

on the php header() man page someone mentioned that you need to add ob_ functions to the script for zip files, but it doesn't make a difference for me if i have them in there or not.

if i download the file manually (and successfully), the headers sent look like this:

HTTP/1.1 200 OK
Date: Wed, 16 Jul 2008 09:45:02 GMT
Content-Type: application/zip
Connection: keep-alive
Server: Apache
Last-Modified: Wed, 16 Jul 2008 09:42:31 GMT
ETag: "31ab3ea-1b0d000-487dc287"
Accept-Ranges: bytes
Content-Length: 28364800

if downloaded via my script, cutting off at 12mb:

HTTP/1.1 200 OK
Date: Wed, 16 Jul 2008 09:42:29 GMT
Server: Apache
X-Powered-By: PHP/5.2.2
Connection: keep-alive, close
Accept-Ranges: bytes
Cache-Control: public, must-revalidate
Content-Disposition: attachment; filename="state.zip"
Content-Transfer-Encoding: binary
Content-Length: 28364800
Content-Type: application/zip

the download window will show the correct file size ("x of 27mb..."), but it still stops at 12mb. it cuts off at the same point no matter what the .zip file size is. any idea what i'm doing wrong?