I have a server-side zip archive that I would like to pass along as a download. I'm using a custom extension to associate these specific archives with some client software (e.g. CustomArchive.bwz).
Chrome and FireFox handle this custom extension perfectly, but Internet Explorer keeps tacking ".zip" at the end of the file name (e.g. CustomArchive.bwz.zip).
Here is my download file method:
function downloadFile($file)
{
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($file));
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
ob_clean();
flush();
readfile($file);
exit;
}
As an example, I am calling it like this:
downloadFile( "CustomArchive.bwz" );
Where CustomArchive.bwz is simply a zip file with a custom extension.
After playing with removing various bits from my downloadFile method, I was able to narrow it down to my calling ob_clean(). Unfortunately, removing that call causes the downloads to be corrupted.
Is there a work around that I can force IE to use the .bwz extension and not tack on .zip?
My server is running PHP 5.3.5 on IIS 7.5.