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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.