PDA

View Full Version : Is there any way to MAKE someone download a webpage?



???
08-20-2007, 05:10 PM
I know gmail does this, but, they do many things. Does anyone else know how?

Twey
08-20-2007, 05:26 PM
You can send a weird content-type that the browser doesn't recognise (e.g. application/x-octet-stream), but it's not guaranteed -- IE for one likes to guess at the content of files you send it. One of the best ways is to zip it up. That way the user deals with the zip file instead of the actual file. In my browser that means opening the zip file in the current tab (it doubles as a file manager) but most browsers don't have Konq's plugin system.

???
08-20-2007, 05:30 PM
How do you tell it what content type it is? Like with a link or Javascript or something.

djr33
08-20-2007, 05:43 PM
<?php header('Content-type: application/x-octet-stream'); ?>
Or any mime-type you'd like.

Headers must be output before any text or other data is sent.

Twey
08-20-2007, 05:52 PM
With the HTTP Content-Type header.

???
08-20-2007, 06:58 PM
So you put that php line at the very top of whatever file?

djr33
08-20-2007, 11:48 PM
Indeed.