Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
How do I force a certain filename in the browser?by cfreak (Chaplain) |
on Jul 11, 2002 at 18:07 UTC ( [id://181095]=perlquestion: print w/replies, xml ) | Need Help?? |
cfreak has asked for the wisdom of the Perl Monks concerning the following question: Okay here's what I'm up to. I have some files that are saved in a directory not accessable from the webserver. (The files come from email attachments but that's beside the point). They are saved there because I only want to allow access to them by the user the owns them. So I have a script that authenticates the user and then retrieves the file for them and prints it to their browser (i have the filetypes saved in a database). If the mime type can be displayed it shows up and if now it asks the user if they want to download the file. This all works great except that when the file needs to be downloaded the browser defaults to the name of the script rather than the filename of the file. I tried sending the filename in the content header, for example a Word Document: print "Content-type: application/msword; filename=mydoc.doc\n\n";However the browser seemed to ignore this. Is there a header that can tell it what filename to use or do I need to find another solution?. BTW I thought about htaccess but then the user would have to authenticate twice as they need to beable to retrieve the file from inside the web based email client I'm working on, so its not really a solution. Thanks in advance
Back to
Seekers of Perl Wisdom
|
|