Page 1 of 1

download a file

Posted: Mon Jun 23, 2003 2:10 am
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

Posted: Mon Jun 23, 2003 2:25 am
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