Samsam Posted June 28, 2010 Share Posted June 28, 2010 hi phpfreaks! i have a part of code which zips images files then allows zipped file to be downloaded.the zip works well but when forcing to download, it recognizes file size as 400 bytes and download corrupts. i run my script on my pc(localhost) may someone help me? $data = implode("", file("myimage.jpg")); $gzdata = gzencode($data, 9); $fp = fopen("myimage.jpg.gz", "w"); fwrite($fp, $gzdata); fclose($fp); $file = "myimage.jpg.zip"; header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Cache-Control: private",false); header ( "Content-Type: applicatio/zip" ); header("Content-Disposition: attachment; filename=\"".$file."\";"); header("Content-Length: " . filesize($file) ."; "); readfile($file); Link to comment https://forums.phpfreaks.com/topic/206043-problem-with-zip-file-download/ Share on other sites More sharing options...
Samsam Posted June 28, 2010 Author Share Posted June 28, 2010 problem solved by editing this line $file = "myimage.jpg.zip"; to $file = "myimage.jpg.gz"; Link to comment https://forums.phpfreaks.com/topic/206043-problem-with-zip-file-download/#findComment-1078128 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.