download a file

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
rajesh_kutty
Forum Newbie
Posts: 1
Joined: Mon Jun 23, 2003 2:10 am
Contact:

download a file

Post by rajesh_kutty »

hi
i am new to php.
i wanted my user, to be able to download the file from my site on to his computer.

for this i gave the following code line

copy ($sourcefile,$destfile);

the sourcefile has the file name with path which the user is going to copy
and the destfile has the path of the users computer where he will be copying the file.

but when i execute the .php file i get the error saying

Warning: copy(d:/) [function.copy]: failed to create stream: Permission denied

why so?

can anybody pls help me fast

regards
rajesh
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

copy() only works on the box where php is running (i.e. the server). Just think about it: Do you want all the morons with a webserver out there have access to your local filesystem? ;)

If you want to serve documents for download via http you have to send this file (like any other document, too)
there's an example at http://www.php.net/manual/en/function.h ... p#AEN31550
Post Reply