Welcome to Dream.In.Code
Become a PHP Expert!

Join 136,909 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,747 people online right now. Registration is fast and FREE... Join Now!




Force download doesn't work with IE7 on remote server

 
Reply to this topicStart new topic

Force download doesn't work with IE7 on remote server

godbout
17 Mar, 2008 - 09:56 PM
Post #1

New D.I.C Head
*

Joined: 17 Mar, 2008
Posts: 1

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

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!

This post has been edited by godbout: 17 Mar, 2008 - 10:01 PM
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/3/08 09:55PM

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month