Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

copying files from one directory to another 1

Status
Not open for further replies.

pushyr

Programmer
Jul 2, 2007
159
GB
i'm trying to copy a file from one directory to another

here's my script so far...

Code:
$path_source = ''.$_SERVER[DOCUMENT_ROOT].'/folder/original/';
$path_destination = ''.$_SERVER[DOCUMENT_ROOT].'/folder/new/';
$file = ''.$path_source.'image.jpg';

copy($file, $path_destination);

but i get the following error...
Warning: copy(/Library/WebServer/Documents/folder/new/) [function.copy]: failed to open stream: Is a directory in /Library/WebServer/Documents/...../test.php on line 14

where am i going wrong?
 
Possibly a permission error but for a start can you echo $path_source , $path_destination and $file please.
 
the issue is that you are specifying a directory as the destination whereas you should specify a path.

Code:
copy($path_source . 'image.jpg', $path_destination . 'image.jpg');
 
jpadie strikes again! cheers... you sorted it!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top