FW: [thelist] http header function does not work in IE 5.0

Matthias Ritzkowski Matt at grndwtr.com
Fri Jun 28 16:23:02 CDT 2002

Hallo Evoltister!

Thanks for all the hints
 - unfortunately none of them worked for me :-(
After searching high and low all afternoon, this works across "all" browsers
(tested on IE 6.0, IE 5.01 SP2, Opera, Mozilla, NN6.2)

<tip downloading files with http headers through ssl>
When you are struggling with Microsoft's bad implemtation of downloading
files via SSL, try this

	$file_path is defined
	$file_name is defined
	$filesize = filesize($file_path);

	if (strstr($_SERVER["HTTP_USER_AGENT"], "MSIE"))
	header("HTTP/1.0 200 OK");
	header("Content-Type: application/pdf");
	header("Content-Disposition: attachment; filename=$file_name");
	header("Content-Location: $file_path");
	header("content-length: $filesize");
	   $fp = fopen("$file_path", "r");
print fread($fp, $filesize);
-----Original Message-----
From: Means, Eric D [mailto:eric.d.means at boeing.com]
Sent: Friday, June 28, 2002 09:37
To: 'thelist at lists.evolt.org'
Subject: RE: [thelist] http header function does not work in IE 5.0

>  -----Original Message-----
> From: 	Matthias Ritzkowski [mailto:Matt at grndwtr.com]
> Sent:	Friday, June 28, 2002 8:01 AM
> To:	Thelist (E-mail)
> Subject:	[thelist] http header function does not work in IE 5.0
> Guten Morgen evoltistas,
> This code  works in any browser, except MSIE
> Has anyone else experienced this and maybe found a solution. None of the
> one's I have found on the web have worked so far.

Hmm, that's odd... I have a couple Perl app that do something very similar,
and they work in IE5.  I have one that serves unknown application types, and
one that serves Excel spreadsheets (generated as CSV files).

The unknown types one prints the following headers:
  #Set Content Type
  print "Content-Type: application/octet-stream\n";
  print "Content-Disposition: attachment; filename=\"$fileName\"\n";
  print "Content-Length: $filesize\n";
  print "\n";

The Excel one prints these headers instead:
  print "Content-Disposition: attachment; filename=troublereports.csv\n";
  print "Content-Type: application/vnd.ms-excel\n";
  print "Cache-control: private\n";
  print "\n";

You could try turning output buffering on at the very beginning of the
script, to make sure no headers are sent prematurely.
Also I note you don't appear to be quoting the filename; I don't know if
that might irritate IE in some cases (e.g. spaces etc in the filename), but
it doesn't appear to in my second example.

You could also start with the minimal headers (Content-Disposition and
-Type) and see if that works; if it does you can start adding headers back
in until it breaks again.

For unsubscribe and other options, including
the Tip Harvester and archive of thelist go to:
http://lists.evolt.org Workers of the Web, evolt !

More information about the thelist mailing list