IE 5.5 bug, Yes, I know.

but what should I do for the idle people who do not update their browsers?

please, tell me the solution.

Brandon M. Wise wrote:

All,

I finally tracked down a solution to this bug with Internet Explorer 5.5 SP 1 for Windows. The fix isn't great, because is isn't a server issue, its a client issue.

There is a bug in mshtml.dll versions older than 5.50.4612.600. This is documented in Microsoft Product Support article Q281119.

The support download (Hotfix) than contains the update to mshtml.dll is Q286045. This Hotfix will update mshtml.dll to version 5.50.4613.1700 and will cause Internet Explorer to properly read the Content-Disposition header.

Hope this help!

Brandon M. Wise

    22 days later

    I used your script on IE5.5 but the page show me a plug-in icon, and IE ask me to download an active-x plug-in.
    Can you tell me why. The other scripts do well on IE5.5 if I open the page as a new browser page.
    Thank you.

      I`ve problems too with this f*** MSIE 5.5

      the poppup window savely come up, but it doesn`t show the real filename!

      the code looks like this:

      $file=mysql_fetch_array($result);
      $type = $file["type"];
      $size = $file["size"];
      $filename = $file["filename"];
      $data = $file["data"];

       header("Content-type:$type");
       header("Content-length:$size");
       header("Content-Disposition: attachment; filename=\"$filename\"");
       header("Content-Description:PHP Generated Data");
       header("Content-Transfer-Encoding: binary");

      with Netscape 6.1 it works fine 🙂

      knows anyone more? it would be greatfull

        17 days later

        Have you encountered the following problem:

        Using IE5.5 through an ISP dial-up connection, when I specify "Content-Length: $size" where $size is the file length, the transfer begins correctly but is terminated straight away, and I get a zero-length file. It works fine with Netscape 6, or with a direct LAN connection.

        By removing the "Content-Length" all is OK with IE (except no progress bar).

        I am running PHP4.0.6 on Linux / Apache.

          8 days later

          Can anyone give me a hand. Below is the code I am trying to use, including Wim's IE fix, but IE still will not connect to the server.

          Lloyd

          <?php

          $file = explode('/', $HTTP_SERVER_VARS['QUERY_STRING']);
          $file_name = array_pop($file);
          if( count($file) )
          $file_path = implode('/', $file) .'/';

          if( $file_size = filesize("$file_path$file_name") )
          {
          // Hack for IE-bug [Wim Vandersmissen]
          if (strstr($HTTP_USER_AGENT, 'MSIE'))
          $attachment = '';
          else
          $attachment = ' attachment;';

          //header("Content-Type: application/octet-stream");
          header("Content-Type: application/ms-x-download");
          header("Content-Length: $file_size");
          header("Content-Disposition: filename=$file_name");
          header("Content-Transfer-Encoding: binary");
          
          
          //$file_handle = fopen("$file_path$file_name", "r");
          //fpassthru($file_handle);
          @readfile("$file_path$file_name");
          exit;

          }

          ?>

          <head>

          File not found.

          </head>

          <body>

          <strong>File not found</strong>
          <br>
          Click <a href='#' onclick="alert(document.location.href); return false;">here</a> to go back.
          <br>

          </body>

            12 days later

            I've perhaps the same problem.
            The download began correctly but it stops at the middle of the download (both with IE and Netscape)

            What can I do ?

              Helo everyone!
              what i can say is:
              my problems were fixed as i insalled ie 5.5 SP2!!!
              its like that: ie5.5 doesnt read the Content-Dispositio Header correctly, an without the correct information, there wont run something correctly. it is that simple 🙂

              in any case, i`ve installed ie 5.5 SP2 and ANYTHING was good 🙂

              And for all of you have problems with ie: have a look at microsoft.com!

              good luck!!

                a month later

                At my end d/l works fine
                i call it with a download?file=... link and so the downloaded file looks like download instead of what is should...
                how can I set this

                  2 months later

                  i am also having a problem with the filedownload. i can get it to download the file, but it also puts the code from the rest of the page in the txt file. here is the code i am using:

                  <?php
                  header ("Content-type: application/force-download");
                  header ("Content-Disposition: $attachment; filename=Signuplist.txt");
                  $size = filesize("test.txt");
                  $fileData = fopen ("test.txt", "r");
                  fpassthru ($fileData);
                  ?>

                    i am also having a problem with the filedownload. i can get it to download the file, but it also puts the code from the rest of the page in the txt file. here is the code i am using:

                    <?php
                    header ("Content-type: application/force-download");
                    header ("Content-Disposition: $attachment; filename=Signuplist.txt");
                    $size = filesize("test.txt");
                    $fileData = fopen ("test.txt", "r");
                    fpassthru ($fileData);
                    ?>

                      you don`t have to put a "$" in front of the "attachment":

                      <?php
                      header ("Content-type: application/force-download");
                      header ("Content-Disposition: attachment; filename=Signuplist.txt");
                      $size = filesize("test.txt");
                      $fileData = fopen ("test.txt", "r");
                      fpassthru ($fileData);
                      ?>

                      and for any other problems with downloading and ie5.5: use SP2, that solves the problems!!

                        ive tried it both ways and i get the same results

                          i think the biggest problem is that i have this code before any of the html code:

                          <?php
                          header ("Content-type: application/force-download");
                          header ("Content-Disposition: $attachment filename=Signuplist.txt");
                          ?>

                          then later in there is an if statement used to verify a password. the file i want to automatically download is created by the code:

                          if ($vinepass==$passwd AND $passwd !=""){

                          $conn = mysql_connect("localhost", "username", "password");
                          $dbtxt = "database";
                          $querytxt = "SELECT * FROM testingsignups WHERE Band=\"$Band\"
                          AND showyear='$showyear' AND showmonth='$showmonth' AND showday='$showday'";
                          $rs = mysql_db_query($dbtxt,$querytxt,$conn);

                          $fp = fopen("$Band-$showyear-$showday-$showmonth.txt", "a");

                          while($myrow = mysql_fetch_array($rs))
                          {
                          $Name = $myrow["Name"];
                          $Street = $myrow["Street"];
                          $City = $myrow["City"];
                          $State = $myrow["State"];
                          $Zip = $myrow["Zip"];
                          $Email = $myrow["Email"];
                          $column = "$Name--$Street--$City--$State--$Zip--$Email\n";
                          $writefile = fputs($fp, $column);
                          }

                          fclose($fp);

                          and i only want the file to be downloaded if the if statement conditions are met. so after the above code i entered this code to download the file:

                          $size = filesize("$Band-$showyear-$showday-$showmonth.txt");
                          $fileData = fopen ("$Band-$showyear-$showday-$showmonth.txt", "r");
                          $str .= chop(fgets($fileData,$size))."\n<br>";
                          fpassthru ($fileData);

                          when the file is downloaded i don't get the contents of the file downloaded, i get the code of the next php script that is run.

                          any ideas on how to correct this problem??

                            i got my document to get created properly, but how do i get it to popup a download prompt to download the file. i am using IE6. here is the code i am using:

                            if ($vinepass==$passwd AND $passwd !=""){

                            $conn = mysql_connect("localhost", "username", "password");
                            $dbtxt = "database";
                            $querytxt = "SELECT * FROM testingsignups WHERE Band=\"$Band\"
                            AND showyear='$showyear' AND showmonth='$showmonth' AND showday='$showday'";
                            $rs = mysql_db_query($dbtxt,$querytxt,$conn);

                            $fp = fopen("$Band-$showyear-$showday-$showmonth.txt", "a");

                            while($myrow = mysql_fetch_array($rs))
                            {
                            $Name = $myrow["Name"];
                            $Street = $myrow["Street"];
                            $City = $myrow["City"];
                            $State = $myrow["State"];
                            $Zip = $myrow["Zip"];
                            $Email = $myrow["Email"];
                            $column = "$Name--$Street--$City--$State--$Zip--$Email\n";
                            $writefile = fputs($fp, $column);
                            }
                            fclose($fp);

                            $FILE = fopen("$Band-$showyear-$showday-$showmonth.txt","r");
                            $NEWFILE = fopen("Signuplist.txt","w");
                            while ($BUFFER = fgets($FILE,4096)) {
                            $writefile = fputs($NEWFILE,$BUFFER);
                            }
                            fclose($FILE);
                            fclose($NEWFILE);

                            any help will be greatly appreciated.

                              18 days later

                              I've just been playing around with downloading files and have developed this for downloading different files types. In this example it separates pdfs and others. It kind of works but when downloading pdf's if you just try and open them directly of the server they aren't recignised, also when saving the pdf's it doesn't automatically use the file name or extention. But uses the file name of the page it is called from.

                              ANy ideas anyone?

                              <?php
                              if (($REQUEST_METHOD != "GET") or empty($file))
                              {
                              Header("Location: /");
                              exit;
                              }

                              // Hack for IE-bug
                              if (strstr($HTTP_USER_AGENT, "MSIE"))
                              {
                              $attachment = "";
                              }
                              else
                              {
                              $attachment = " attachment;";
                              }

                              //check for file extention
                              $filename="$file";

                              $filetype = substr($filename,strrpos($filename,".")+1);

                              //if its got a pdf extention
                              if ($filetype == 'pdf')
                              {
                              $filename = "$label/$file";
                              $size = filesize($filename);

                              Header("Content-Type: application/x-ms-download");
                              Header("Content-Length: $size");
                              Header("Content-Disposition:$attachment; filename=$filename");

                              @readfile($filename);
                              exit;
                              }

                              else
                              //other wise do this, could be more checks but I knew the files would only ever be pdf or txt
                              {
                              $f = fopen("$label/$file", "r");
                              $size = filesize("$label/$file");

                              header("Content-Type: application/x-ms-download");
                              header("Content-Length: $size");
                              header("Content-Disposition:$attachment filename=$file");
                              header("Content-Transfer-Encoding: binary");

                              fpassthru($f);
                              exit;
                              }

                              ?>

                                an up date after reading the latest from drakko which I discovered whiule posting the last.

                                change the line

                                Header("Content-Disposition:$attachment; filename=$filename");

                                to

                                Header("Content-Disposition:$attachment filename=.$file");

                                partly solves the file name issue but still not recognised straight from server.

                                  Just to finish it all I got the pdf to open simply by placing the file var between " " in the pdf script so the full working version is now.

                                  <?php
                                  if (($REQUEST_METHOD != "GET") or empty($file))
                                  {
                                  Header("Location: /");
                                  exit;
                                  }

                                  // Hack for IE-bug
                                  if (strstr($HTTP_USER_AGENT, "MSIE"))
                                  {
                                  $attachment = "";
                                  }
                                  else
                                  {
                                  $attachment = " attachment;";
                                  }

                                  //check for file extention
                                  $filename="$file";

                                  $filetype = substr($filename,strrpos($filename,".")+1);

                                  //if its got a pdf extention
                                  if ($filetype == 'pdf')
                                  {
                                  //get the file from the directory its in $label
                                  $filename = "$label/$file";
                                  $size = filesize($filename);

                                  Header("Content-Type: application/x-ms-download");
                                  Header("Content-Length: $size");
                                  Header("Content-Disposition:$attachment filename=\".$file\"");

                                  @readfile($filename);

                                  }

                                  else
                                  //other wise do this, could be more checks but I knew the files would only ever be pdf or txt
                                  {
                                  $f = fopen("$label/$file", "r");
                                  $size = filesize("$label/$file");

                                  header("Content-Type: application/x-ms-download");
                                  header("Content-Length: $size");
                                  header("Content-Disposition:$attachment filename=$file");
                                  header("Content-Transfer-Encoding: binary");

                                  fpassthru($f);
                                  exit;
                                  }

                                  ?>

                                  Hope this can help someone at sometime.

                                    6 days later

                                    Everything works well now, ie downloads everything, except for .mov files who seem to be overridden by the plugin, the thing is tho, the move doesn't work either...

                                    when saving the .mov file, the movie is saved well.

                                    Somebody knows how to override these types of plugins?

                                    source I'm currently using:

                                    if (strstr($HTTP_USER_AGENT, "MSIE")){
                                    $mime="application/x-ms-download";
                                    $attachment = "";
                                    }
                                    else {
                                    $mime = $download["filetype"];
                                    $attachment = "attachment";
                                    }

                                    header('Cache-Control: no-cache, must-revalidate');

                                    header('Pragma: no-cache');

                                    header("Content-type: $mime");
                                    header("Content-length: ".(string)(filesize($download["filepath"])));
                                    header("Content-Disposition: $attachment; filename=\"".basename($download["filepath"]));
                                    header("Content-Transfer-Encoding: binary");

                                    $downloadfile = fopen($download["filepath"],"rb");
                                    fpassthru($downloadfile);
                                    fclose($downloadfile);

                                    fflush();

                                    thanx,
                                    Koen Antonissen