Page 1 of 1

rename() getting permission denied error

Posted: Sat May 27, 2006 11:49 am
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?

Posted: Sat May 27, 2006 11:52 am
by hawleyjr
Have you tried to use the full directory path with the new image name?

Posted: Sat May 27, 2006 12:03 pm
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 );

Posted: Sat May 27, 2006 12:07 pm
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?

Posted: Sat May 27, 2006 1:59 pm
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!