Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unable to change permissions on uploaded files

Status
Not open for further replies.

MasterKaos

Programmer
Jan 17, 2004
107
GB
I've used PHP to handle file uploads of image files and write them to a directory that has permission 777:
Code:
move_uploaded_file($_FILES['image']['tmp_name'], "../images/accomodation/".$image_id.$extension);

The uploaded images are displayed alright by the browser, but i can't read them using FTP. Checking their permissions they are set to 600. Right clicking them and changing their permisions using WS FTP Pro does nothing.

So i tried using a PHP script to change the permissions:
Code:
if ($handle = opendir('images/accomodation')) 
{
    while (false !== ($file = readdir($handle))) 
	{ 
        echo "$file\n";
		chmod ("images/accomodation/" . $file, 0766);
    }
    closedir($handle); 
}

But when i run the script i get the error:
"Warning: chmod(): Permission denied in /home/ausget/public_html/chmods.php on line 8"

I don't get it, if PHP created the files, why does it not have permission to chmod them? How can i chmod all the existing files so that i can use FTP to copy them? Oh and the path and stuff is correct because the script outputs the correct filenames.

----------------------------------------------------------------------------
The first 90% of the code accounts for the first 90% of the development time. The remaining 10% of the code accounts for the other 90% of the development time.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top