I've read in at least one place (a PHP book I think) that browsers are very inconsistent in their handling of the content-disposition header. Some will "believe" the suggested filename, but
ignore the extension, and implied file type.

Have you considered looping back to your own script with a redirect, something like-

a) User invokes script as "script.pl"

b) Script redirects to "script_downloader.zip"
  (But configure Apache to pass this back to the original script).

c) Script picks up the original session state and emits the zip filestream to the browser,
  which is now expecting a downloadable file type.

May be worth a try.

Regards: Colin

Dermot Paikkos wrote:

On 31 Aug 2005 at 13:48, Michael Peters wrote:

There is a way to do it, defined as part of HTTP or MIME -- I can't
quite remember.  If you do an external redirect you won't have to bother
figuring it out.
If you are generating your own content headers you use the
Content-Disposition header.

Something like:
   $r->header_out(
       'Content-Disposition' => 'inline; filename=my_cool_stuff.zip'
   );


I really hoped that this would have nailed it but alas, no. I am getting a download dialogue prompt but I'm not able to configure a filename for the download.

I tried a few variations with header_out. Specifying a location rather than a internal_redirect to see if that would ensure I was setting the headers. I tried to end the handler with a REDIRECT rather than an OK status, thinking that this was a really a redirect. I also tried to pass the handler to another but that didn't work either. I also had a look at RFC 2183 which refers mostly to MTUs but seems to suggest thst content-disposition is the correct header.

Content does appear to be set, the value of $content below is content = inline;filename=Myzip.zip. I have tried attachment as well out of sheer desperation.

...
print STDERR "redirecting, length=$length, ";
$r->header_out(
       'Content-Disposition' => 'inline;filename=Myzip.zip',
       'Location' => 'http://austin/Myzip.zip'
       );
my $content = $r->header_out('Content-Disposition');
print STDERR "content = $content\n";

# $r->internal_redirect("http://austin/Myzip.zip";);

return REDIRECT;
}
1;

If anyone has any pointers, I'd be grateful.
Thanx.
Dp.




Reply via email to