networkthis Posted June 23, 2008 Share Posted June 23, 2008 I am trying to force the download of a zip file to the browser using php. I am having difficulties getting this to work. Any ideas??? Thanks in advance Link to comment https://forums.phpfreaks.com/topic/111435-solved-force-download-of-zip-file/ Share on other sites More sharing options...
networkthis Posted June 23, 2008 Author Share Posted June 23, 2008 Okay, about 2 minutes after posting this I figured it out thank you. Link to comment https://forums.phpfreaks.com/topic/111435-solved-force-download-of-zip-file/#findComment-572005 Share on other sites More sharing options...
maxudaskin Posted June 23, 2008 Share Posted June 23, 2008 You mean, force someone to download a file to their computer, even if they don't want to? Nobody will help you do that because it is illegal. If these are not your intentions, please post more information about what you want. Link to comment https://forums.phpfreaks.com/topic/111435-solved-force-download-of-zip-file/#findComment-572006 Share on other sites More sharing options...
PFMaBiSmAd Posted June 23, 2008 Share Posted June 23, 2008 "forcing a download" simply means causing the file to be downloaded instead of being opened in the browser or associated application. Link to comment https://forums.phpfreaks.com/topic/111435-solved-force-download-of-zip-file/#findComment-572007 Share on other sites More sharing options...
DarkWater Posted June 23, 2008 Share Posted June 23, 2008 For anyone curious to know the solution, you just send the proper Content-Disposition headers (should be "attachment"). Link to comment https://forums.phpfreaks.com/topic/111435-solved-force-download-of-zip-file/#findComment-572009 Share on other sites More sharing options...
networkthis Posted June 23, 2008 Author Share Posted June 23, 2008 I am not trying to FORCE the download on peoples computers........ Simply trying to allow users to select files they want to download...place them into a zipfile and download them onto their computer instead of having to select them one by one and download them one by one - wasting most of their day... Here is what I did <?php // My Zip file to Download $zipfile = "myZip.zip"; header("Pragma: public"); // set expiration time header("Expires: 0"); // browser must download file from server instead of cache header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); // force download dialog header("Content-Type: application/force-download"); header("Content-Type: application/zip"); header("Content-Type: application/download"); // Display the save dialog to the user with the filename header("Content-Disposition: attachment; filename=".basename($zipfile).";"); // Shows a progress bar for the downloading file header("Content-Transfer-Encoding: binary"); header("Content-Length: ".filesize($zipfile)); @readfile($zipfile); ?> Link to comment https://forums.phpfreaks.com/topic/111435-solved-force-download-of-zip-file/#findComment-572015 Share on other sites More sharing options...
CMK08 Posted October 13, 2008 Share Posted October 13, 2008 I tried this script but it corrupts my zip file. After download, there file can't be open. Ideas? Link to comment https://forums.phpfreaks.com/topic/111435-solved-force-download-of-zip-file/#findComment-664427 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.