Downloading with header()

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Xgtx
Forum Newbie
Posts: 1
Joined: Fri Dec 20, 2002 2:50 pm

Downloading with header()

Post by Xgtx »

I am trying to use the header() function to have users download a file. It is a binary file (extention: xgt - a custom one from my company), and I am using content-type: application/octet-stream. The download begins, but incorrectly. IE appends .htm to the file (file.xgt.htm), and Netscape/Mozilla append .php. Does anyone know how to work around this? I used to have the files zipped, which worked fine, but my boss has told me that he no longer wants the users to download a zip file.
evilcoder
Forum Contributor
Posts: 345
Joined: Tue Dec 17, 2002 5:37 am
Location: Sydney, Australia

Post by evilcoder »

Sorry about a bit of a dud response, but you could try making a page which just displays a link to the file and a bit of text that says

(Right Click and Choose Save File As)

i will look into PHP's ability to force downloading, but i'm not sure at the moment, sorry thats the best i could think of. Maybe tell your boss that .zip is the most effective way to allow downloads.
Peter A. Shushpanov
Forum Newbie
Posts: 4
Joined: Mon Dec 23, 2002 3:38 am
Location: Russia
Contact:

Re: Downloading with header()

Post by Peter A. Shushpanov »

Xgtx wrote:I am trying to use the header() function to have users download a file. It is a binary file (extention: xgt - a custom one from my company), and I am using content-type: application/octet-stream. The download begins, but incorrectly. IE appends .htm to the file (file.xgt.htm), and Netscape/Mozilla append .php. Does anyone know how to work around this? I used to have the files zipped, which worked fine, but my boss has told me that he no longer wants the users to download a zip file.
Why you are using "Content-type: application/octet-stream"?
Try "Content-Type: application/xgt". IMHO it works much better :)
Post Reply