Jump to content

[SOLVED] copying directories


loganbest

Recommended Posts

I'm wanting to copy a complete directory from one location to another with this script:

$DOCUMENT_ROOT=$HTTP_SERVER_VARS['DOCUMENT_ROOT'];
	$startletter = $username{0};
	$oldletter = $oldid{0};
	$getroot = "/home/whatego/public_html";
	@mkdir("/home/whatego/public_html/user_pics/$startletter");
	@mkdir("/home/whatego/public_html/user_pics/$startletter/$newid");
	$newfolder = "/home/whatego/public_html/user_pics/$startletter/$newid";
	$oldfolder = "/home/whatego/public_html/user_pics/$oldletter/$oldid";
	$good = copy($oldfolder,$newfolder);
	if ($good) {echo'Moving pictures success'; } else { echo'Moving pictures failed!';}

 

I always get this error:

 

Warning: copy(/home/whatego/public_html/user_pics/7/7) [function.copy]: failed to open stream: Is a directory in /home/whatego/public_html/changeuser.php on line 89

Moving pictures failed!

 

the copy() manual on php.net said ti would overwrite everything in that directory, though it's not

Link to comment
https://forums.phpfreaks.com/topic/82611-solved-copying-directories/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.