daneth1712 Posted February 19, 2013 Share Posted February 19, 2013 Hi guys, I am having some problems that I hope someone can help me with. Basically I have a page that I need to initiate a download and then refresh the page afterwards. Right now everything seems to work fine in Firefox, but not in IE, Safari or Chrome. Firstly, there are 2 actions on the page; 1. Downloads 1 image file (info needs to be added to the database) and then page must refresh after so image downloaded is removed from the page. 2. Zip file is downloaded with all images on the page. Again info must be added to the database and the page refreshed. The code below should bring up the image to download and then fire off a refresh page (added google link for now). //set download file headers define('MP_BOUNDARY', '--'.sha1(microtime(true))); header('Content-Type: multipart/x-mixed-replace; boundary="'.MP_BOUNDARY.'"'); flush(); echo "Content-Type: ".$filetype."\r\n"; echo "Content-Disposition: attachment; filename=".$filename."\r\n"; echo "\r\n"; //force file download $handle = fopen($path, "rb"); if ($handle) { while (!feof($handle)) { echo(fread($handle, 8192)); } fclose($handle); } echo MP_BOUNDARY; flush(); //flush headers and send HTML headers and refresh page echo "Content-Type: text/html\r\n"; echo "\r\n"; echo '<html><script type="text/javascript">location.href="http://www.google.com";</script></html>'; echo MP_BOUNDARY.'--'; flush(); The zip file works in the same may except process happens beforehand to add all the files in to a zip. Any help would be really appreciated. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/274674-multipartx-mixed-replace-headers/ Share on other sites More sharing options...
daneth1712 Posted February 19, 2013 Author Share Posted February 19, 2013 Or is there another way I can do what I need? Just in case I didnt explain properly.... I have a page, the page has multiple forms. Each 'small' form requests a single image download. The 'large' form downloads all images as a zip file. The part of downloading the single or zip file works fine. What I need to get is the page to refresh after the download has appeared so that the images downloaded are removed from the list. If single image download just remove that 1 from list, and if downloaded as zip for all images that it removes everything from the list. I dont know a way of making this work in all browsers and I really need to come up with a solution to this ASAP. Thanks in advance to whoever can help me. Daniel Quote Link to comment https://forums.phpfreaks.com/topic/274674-multipartx-mixed-replace-headers/#findComment-1413391 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.