sending a file to the browser for download automatically

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
maltune
Forum Newbie
Posts: 1
Joined: Sat Dec 14, 2002 9:38 pm

sending a file to the browser for download automatically

Post by maltune »

I'm wanting to write a script that will allow users to download a file without being able to see where the file's stored or be able to download it if he/she isn't logged in and a session created. I've seen lots of sites that have this for downloading files (sourceforge.net, tucows.com ect).

For example: sites will sometimes have something saying "download will start shortly, click here if nothing happens" and then the file is sent automatically after the page is loaded.

Has anyone done this before? I'm thinking maybe I have to send the appropriate headers and stream the output of the file I want to send??

Anyone have a suggestion?

thanks,
jeremy
evilcoder
Forum Contributor
Posts: 345
Joined: Tue Dec 17, 2002 5:37 am
Location: Sydney, Australia

Post by evilcoder »

Yeah, i do this on my site.

http://www.clandazed.com/?com=DigitalPictures

Check that out see if that's what your after.

But as with any script like that, it took me under 5 minutes to make and is about as secure as simple download scripts go, but no matter what you use, people will always be able to find out where the file is coming from, you can't fool HTTP redirects.
Post Reply