Hi there,
I’ve got a really strange problem and I’ve already spent too much time on it for the small thing it is.
I’ve got 2 php pages. One is the main one, calling the second one. The second is just a page to force the download of a file.
When I use them locally, I don’t have any problem. It works well with IE and FF. The ‘Save dialog box” appears in both cases, and I case save or open my file perfectly.
But when I put the file on my remote server, it works well with FF but doesn’t work anymore with IE7. IE7 opens the second page but close it automatically and immediately. The “Save dialog box” never appears, and I cannot find the reason.
After 2 days of trying to understand what’s happening, I gave up (quite often with IE).
I chose another solution, not the one I wanted, but I cannot loose too much time with that.
Anyway, I would still understand what’s happening, if anybody gets an idea.
Here is the code used:
In the main page, to call the second php file
[code]
echo ‘<script language=”JavaScript”>window.open(‘dl.php?filename=’ .basename( $appFile ) .”,’download’)</script>’;
The second page
[code]
<?php
$filename = ‘../appFiles/’. $_GET[‘filename’];
if ( substr(strrchr($filename, ‘.’), 1) == ‘xls’ )
{
if(ini_get(‘zlib.output_compression’))
ini_set(‘zlib.output_compression’, ‘Off’);
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: application/octet-stream”);
header(“Content-Disposition: attachment; filename=””.basename($filename).””;”);
header(“Content-Length: “.@filesize($filename));
set_time_limit(0);
readfile(“$filename”) or die(“File not found.”);
}
?>
Thanks for your help!