Page 1 of 1

Mozilla problems with headers to send a file

Posted: Mon Oct 10, 2005 11:49 am
by jeffxl
Jcart | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]


I'm writing script that will read a file location from a database, and then allow the user to download it.  To do this, I set headers as follows, where $ft, $fn, and $fs are the file type, file name, and file size, respectively:

Code: Select all

header ("Content-Type: application/$ft");
header ("Content-Disposition: attachment; filename=$fn");
header ("Content-Length: $fs");
The problem occurs in the differences between the way Firefox handles this request, and Internet Explorer, Safari, and others handle it. If my file name has spaces in it, such as "This PDF Document.pdf", a Mozilla client will pop up the save window prompting me to save the file "This", where as anything other client will will pop up the window prompting me to save the correct name "This PDF Document.pdf". Further, with the mozilla clients, if I do save the file, nothing will open it even if I modify the file extension manually.

Does anyone know a way around this, or perhaps something I'm doing wrong?


Jcart | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]

Posted: Mon Oct 10, 2005 12:35 pm
by John Cartwright
Not positive, but try urlencode()

Posted: Mon Oct 10, 2005 12:44 pm
by jeffxl
I tried that, but it just made the file show up as "This+PDF+Document.pdf". Still not the true file name.