Jump to content

Archived

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

SharkBait

move_uploaded_file - Permissions

Recommended Posts

Ok this is driving me nuts.

I have a small script that uses move_uploaded_file() but I keep getting the Permission Denied.

The file that calls move_uploaded_file() I changed its permission to 777 as well as the folder its going to.

The bit of code looks like:

[code]
<?php

if(move_uploaded_file($file_tmp_name, "photos/{$filename}")) {
  // Good
} else {
  // Not good
}
?>
[/code]
[/code]
The file is under 100kb in size. This is the error msg i am getting:

[code]
Warning: move_uploaded_file(photos/ChelseaCard.jpg) [function.move-uploaded-file]: failed to open stream: Permission denied in /home/tingram/public_html/tingram/imageUpload.php on line 36

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpS5YP17' to 'photos/ChelseaCard.jpg' in /home/tingram/public_html/tingram/imageUpload.php on line 36
Error moving file
[/code]

Is there a setting in php.ini I need to look at?  I use this type of script on another server and it works fine...
=-)

Share this post


Link to post
Share on other sites
Yes, I am having a similar problem. See the post I started yesterday labeled 'move_uploaded_file & upload_tmp_dir'.

Share this post


Link to post
Share on other sites
Could it be because we don't have read/write access to the tmp file on our test machines?

Share this post


Link to post
Share on other sites
How would we know? The temp directory is not part of IIS....it's on another drive actually....

Share this post


Link to post
Share on other sites
Well I turned on E_Notice in the php.ini and when I tried uploading the image, I must of spelt the varible name for the temp file... But why it was giving me a Permission Denied error, why not tell me if couldnt find the tmp file I specified without having to use file_exists().

But now since my little test server doesnt have GD2.0 on it, i gota figure out how to update PHP and the GD.

Share this post


Link to post
Share on other sites
Check with your host as to whether they allow CHMOD777.  My host (LunarPages) does not allow you to set your permissions to this.  I have been told by them to use 755 for folders and 644 for files.  Try these and see what happens.

Share this post


Link to post
Share on other sites
My error is occuring on my PC where I am running IIS on XP and have set the folder to 'write' in IIS.....

Share this post


Link to post
Share on other sites

×

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.