Force download doesn't work with IE7 on remote server

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
godbout
Forum Newbie
Posts: 2
Joined: Tue Mar 18, 2008 12:28 am

Force download doesn't work with IE7 on remote server

Post by godbout »

Hi there,

I've got a 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: Select all

 
echo '<script language="JavaScript">window.open(\'dl.php?filename=' .basename( $appFile ) .'\',\'download\')</script>';
 
The second page

Code: Select all

 
<?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!
godbout
Forum Newbie
Posts: 2
Joined: Tue Mar 18, 2008 12:28 am

Re: Force download doesn't work with IE7 on remote server

Post by godbout »

Any idea?
Post Reply