Jump to content


Issue streaming files in IE

  • Please log in to reply
No replies to this topic

#1 HardlyNoticable

  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 05 September 2006 - 12:13 PM

Hi There,

I'm building a web based upload/download app for my work in PHP.  We have a lot of clients that we transfer files back and forth with and have some very specific processes that we wish to employ.

For downloading, I am streaming the file to the client's web browser (this way we can control access and do application level logging).  However I am having a problem getting it to work properly in IE.

In IE, if the user saves the file, everything works fine.  But if the user opens the file directly, the browser downloads the file and then doesn't open it.  If the file is a PDF, the IE downloads the file, and acrobat reader starts, and then says it can't find the file.  I suspect the file is downloading under one name (probably the correct one) and then the browser or reader is trying to open it under another name (probably the name of the php page that's streaming the file). 

Has anyone here ever encountered this problem?  I suspect it may have something to do with the header that I'm sending to the client's browser.  I should mention that Firefox and Safari are not having any issues (only IE) and that I have tried this on multiple machines.

The following is the code I'm using for the actual download:

else // Usual download
   header("HTTP/1.1 200 OK");
   header("Content-Length: $filesize");
   header("Content-Type: application/force-download");
   header("Content-Disposition: attachment; filename=$root_filename");
   header("Content-Transfer-Encoding: binary");

   if(file_exists($filepath) && $fh = fopen($filepath, "rb")){
       while($buf = fread($fh, $bufsize))
           print $buf;
	   set_activityrecord(0, "File downloaded - no error.");
       header("HTTP/1.1 404 Not Found");
	   set_activityrecord(3, "File not found on download.");

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users