rename() getting permission denied error

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
clem_c_rock
Forum Commoner
Posts: 46
Joined: Mon Jun 07, 2004 9:18 am

rename() getting permission denied error

Post by clem_c_rock »

Hello,

I'm having an interesting problem with some file upload issues.

I am uploading photos into a directory w/ 777 permissions and right after the photo is uploaded into the directory, I user the chmod command to set the permissions of the uploaded photo to 777 as well. Then I try to use the rename command to change the name of the photo and I get a permission denied error.

Here's the code I'm using:

Code: Select all

$new_thumbnail_name     = $catalogue_id . '_tn_' . $item_thumbnail_path;
 if( file_exists( "../../uploaded_gallery_photos/$item_thumbnail_path" ) ){ echo "<br>YESS!!!!!"; }else{ echo "<br> NO!!!!!"; } //for testing purposes - this alway reports that the file exists

rename( "../../uploaded_gallery_photos/$tem_thumbnail_path",   $new_thumbnail_name );
Completely weird,
Any ideas?
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

Have you tried to use the full directory path with the new image name?
clem_c_rock
Forum Commoner
Posts: 46
Joined: Mon Jun 07, 2004 9:18 am

Post by clem_c_rock »

Yeah - I've tried this as well and get the same error message:


rename( $_SERVER['DOCUMENT_ROOT'] . "/uploaded_gallery_photos/$tem_thumbnail_path", $new_thumbnail_name );
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

clem_c_rock wrote:Yeah - I've tried this as well and get the same error message:


rename( $_SERVER['DOCUMENT_ROOT'] . "/uploaded_gallery_photos/$tem_thumbnail_path", $new_thumbnail_name );
Are you setting $new_thumbnail_name to a full dir path?
clem_c_rock
Forum Commoner
Posts: 46
Joined: Mon Jun 07, 2004 9:18 am

Post by clem_c_rock »

I'm such a dumbass - no I didn't do that and when I did = problem solved.

I think I should get more sleep!

Thanks for your help!
Post Reply