Jump to content

chown in PHP


dsartain

Recommended Posts

I'm running an FC 6 server with PHP/mysql installed...I'm making a php page/script that will allow a user to upload images.  The problem is that I want all images uploaded to be chmod 0644 so that no one else can delete them, I got that to work, but the user that uploads the images is apache.  So I'm trying to do a chown (see below) to give the actual user ownership, but I get the error below...

 

Warning: chown() [function.chown]: Unable to find uid for jjhughes:jjhughes in /var/www/html/jjhughes/gallery_up.php on line 70

 

if(is_uploaded_file($userfile_t))
{

if(!move_uploaded_file($userfile_t, $upfile1))
	{
		echo "Could not move files to destination directory";
		exit;
	}
	if(!chmod($upfile1, 0644))
	{
		echo "Could not modify file permissions";
	}
	chown($upfile1, 'username');

$pic_link_t='http://www.the24hourshow.net/jjhughes/images/gallery/thumbnails/'.$userfile_t_name;
echo "File uploaded successfully! <br />";
}
else
{
echo "Possible file upload attack Filename: ".$userfile_t_name;
exit;
}

 

Any ideas on how to work this out...other than chmod 0777???

Link to comment
https://forums.phpfreaks.com/topic/37849-chown-in-php/
Share on other sites

the error you are getting is because the user doesn't exits on the *nix machine.

 

my simple work around would be to chmod the file so that no one can delete it.

 

then when the user wishes to delete it, chmod it back to 777 and allow deletion.

 

chris

Link to comment
https://forums.phpfreaks.com/topic/37849-chown-in-php/#findComment-181217
Share on other sites

but the user does exist on the machine...I just checked the passwd file to make sure...but I guess I could always put a delete button under the pic (inside some sort of control panel) so when she wanted to delete it she would just do it from there, and then apache would end up deleting it anyway....

Link to comment
https://forums.phpfreaks.com/topic/37849-chown-in-php/#findComment-181222
Share on other sites

Archived

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

×
×
  • Create New...

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.