
tshinnicatio.com
Aug 30, 2005, 8:26 PM
Post #2 of 3
(146 views)
Permalink
|
At 12:18 8/30/2005, Mutant wrote: >Hi, > >Is there any way to use the 'Content-Disposition' header with Catalyst to prompt the user to download a file? > >Using the Apache module, I'd simply set up the header, open the file, and print the contents to STDOUT. > >Under Catalyst doing this, or setting $c->res->body() to the contents causes the file to get corrupted (because it's treating it as text?) > >Any help would be appreciated. Others will no doubt know better, but this from my notes: Use the 'attachment' keyword on content-disposition to hint to the browser that this file should not be displayed but rather saved: Content-Disposition: attachment; filename="Culver_OL_2.LAS" Use the 'name' on the content-type as yet another way (in addition to the above) to suggest what the saved filename should default to: Content-Type: application/octet-stream; name="Culver_OL_2.LAS" Of course the actual mime type _should_ be accurate, like "application/pdf", but using "application/octet-stream" is supposed to help the browser decided to save as a file rather than try to display. >Thanks, >Sam.
|