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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.