copy() - no worky

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
aybra
Forum Commoner
Posts: 56
Joined: Sun Nov 24, 2002 12:52 am

copy() - no worky

Post by aybra »

My code -

Code: Select all

$Afile = "index.php";
$newfile = "index.php.bak";
if (!copy($Afile, $newfile)) {
   echo "failed to copy $Afile...<br>";
}
echo '',$Afile,' - ',$newfile,'';
My problem -

This code works just fine on my localhost - but i upload to my server and it just errors out.

My PHPinfo()

Is it a problem with the code - or a problem with the server?
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

Check out chmod() to modify your directory permissions.
aybra
Forum Commoner
Posts: 56
Joined: Sun Nov 24, 2002 12:52 am

Post by aybra »

I thought about that - the folder is 755 - and so are the files in question.
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

What errors are you getting?
aybra
Forum Commoner
Posts: 56
Joined: Sun Nov 24, 2002 12:52 am

Post by aybra »

Warning: copy(index.php.bak) [function.copy]: failed to open stream: Permission denied in /home/sackettc/public_html/gallery/move.php on line 16
But i cant figure out why i'm getting a permissions error. I've gone over all directories clear up to root - and i'm 775 the whole way up.. i even set this script to run 4775...

This makes no sence to me.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

So the user executing php is the owner or in the group of the directory?
aybra
Forum Commoner
Posts: 56
Joined: Sun Nov 24, 2002 12:52 am

Post by aybra »

in short.. yes.

The script is running under the owner and group of the directory...

I guess it just has to be something with the configuration of the server.. i should prolly put on my sperluncing gear and try to figure out where the permission set is.
Post Reply