php download script

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
toms100
Forum Contributor
Posts: 119
Joined: Wed Feb 26, 2003 10:29 am
Location: Bristol,UK

php download script

Post by toms100 »

hi
im trying to make a php download script, but im not sure how i would go about stopping the browser downloading the file unless it has gone through the script. ill use .htaccess on the folder with the files, but how do i make php allow the user to download?

hope someone can help

Tom
User avatar
d-m
Forum Commoner
Posts: 31
Joined: Fri Aug 29, 2003 4:24 pm
Location: Rio de Janeiro - RJ - Brasil

Re: php download script

Post by d-m »

toms100 wrote:hi
im trying to make a php download script, but im not sure how i would go about stopping the browser downloading the file unless it has gone through the script. ill use .htaccess on the folder with the files, but how do i make php allow the user to download?

hope someone can help

Tom
If you make apache the autenticator using .htaccess ... The user only enters at these area if he is alowded . (Alowded to download the file I mean)

So you just make a page with a href to the file ... and the user download the file .

Other users that do not autenticate 'll not be able to get it... Apache .htaccess 'll do the job for U.


Other way that you can do it in php is having a user name and pass at a database, autenticate the user .. if the user have a download status at the database you include an a href to the file at your php file.

I hope that I could help U.
toms100
Forum Contributor
Posts: 119
Joined: Wed Feb 26, 2003 10:29 am
Location: Bristol,UK

Post by toms100 »

thanks for the idea
in irc someone mentioned using readfile(), ill investigate that too:)
Post Reply