Advertisement

08.19.2008 at 10:42PM PDT, ID: 23662109
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.2

How do you force download in IE6 with PHP?

Asked by greligioso1 in Internet Explorer Web Browser, Web Browsers, Web Development

Tags: , ,

Hello,

Before I begin, here is our current client setup that we are having issues with.

- Windows XP SP3
- Internet Explorer 6 SP3

We are having an issue with forcing a download of an MP3 in Internet Explorer 6 and sometimes 7.  Mozilla(Firefox 2 & 3) and Safari 3.x work fine and bring up the Save As dialog box correctly.

This is what is happening.  A user clicks on a button in a Flash Application to initiate a call to a file called download.php, which initiates the force download of the MP3 using the header() php functions.  The Save As dialog box appears correctly, but instead of downloading the MP3, it tries to download whatever is at the end of the URL, directory name or file name.  An example is if the URL is like [url]http://www.domain.com/directory[/url], it tries to download "directory".  If we type in the URL directly like [url]http://www.domain.com/download.php[/url] it tries to download "download_php".  In every other browser, it will initiate a download and download the MP3 correctly, but in IE it will not download the MP3 and will just timeout.  

At the Save As dialog box, if you click on Open it tries to open in Windows Media Player, but fails because it is trying to download a file that doesn't exist.  If you click Save, it times out because it is trying to download a file that doesn't exists.  If you click Cancel, then click on the button in the Flash Application to initiate a call to download.php, it downloads the MP3 without any issues.

We understand there have been issues with IE with Content-Disposition since 4.0 ([url]http://www.jtricks.com/bits/content_disposition.html[/url]), but was wondering if anyone has come up with a solution or a workaround.  Below is the code we are currently using.

if(ini_get('zlib.output_compression')) { ini_set('zlib.output_compression', 'Off'); }  
     // get the file mime type using the file extension  
     switch(strtolower(substr(strrchr($file_name,'.'),1)))  
     {  
         case 'pdf': $mime = 'application/pdf'; break;  
         case 'zip': $mime = 'application/zip'; break;  
         case 'jpeg':  
         case 'jpg': $mime = 'image/jpg'; break;
             case 'mp3': $mime = 'audio/mpeg'; break;
         default: $mime = 'application/force-download'; break;  
     }  
      header('Pragma: public');   // required  
    header('Expires: 0');       // no cache  
    header('Cache-Control: must-revalidate, post-check=0, pre-check=0');  
    header('Cache-Control: private',false);
      
      //if(!ereg("MSIE 7.0",$_SERVER['HTTP_USER_AGENT'])){
            //removing the Content Type for IE 7 seems to work
            header('Content-Type: '.$mime);
      //}
      header("Accept-Ranges: bytes");       
    header("Content-Disposition: attachment; filename=\"".basename($file_name)."\"");  
    header('Content-Transfer-Encoding: binary');  
    header('Content-Length: '.filesize($file_name));    // provide file size

    readfile($file_name);       // push it out  */

All help is welcome.

Thanks in advanced!Start Free Trial
[+][-]08.19.2008 at 11:12PM PDT, ID: 22266614

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.20.2008 at 04:24AM PDT, ID: 22268181

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08.20.2008 at 11:14AM PDT, ID: 22272370

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.21.2008 at 01:23PM PDT, ID: 22283973

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Internet Explorer Web Browser, Web Browsers, Web Development
Tags: PHP, Internet Explorer 6, header() Content-Disposition Force Download
Sign Up Now!
Solution Provided By: greligioso1
Participating Experts: 2
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628