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