You don't actually need to zip the file to make it download. The method I would tend to use is to push the request for the file/image through a script that reads in the real file's data and passes it out to the browser. This allows you to set headers, forcing the download, and also gives you a significant amount of flexibility for throttling and tracking downloads:
PHP Code:
if ($filehandle = fopen($filepath, 'rb')) { //open binary file for reading
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header('Content-type: application/force-download');
header('Content-Disposition: attachment; filename="' . $filename . '";' );
header('Content-Length: ' . filesize($filepath));
header('Content-Transfer-Encoding: binary');
while( !feof($filehandle) && connection_status()==0 ) {
echo fread($filehandle, 1024*8);//send in 1kb chunks
flush();
}
fclose($file);
}
I've not tested that code, but I hope it demonstrates what I mean.
Bookmarks