Page 1 of 1

Uploading images

Posted: Mon Jan 26, 2009 1:24 pm
by QbertsBrother
i have a page that allows people to upload an image. what happens after they upload it it gets set with the user and group apache what i would like to have it do is upload it with a user and group that i specify such as webuser.

here is the code that i user to upload the images.

Code: Select all

$ran = date("dmY");
$ran2 = $ran.".";
$target = "../inc/images/events/";
 
$target = $target . str_replace(" ", "", $_POST['eventname']).$ran2.$ext; 
move_uploaded_file($_FILES['eventimage']['tmp_name'], $target);
$eventimage = str_replace(" ", "", "events/".$_POST['eventname']).$ran2.$ext;
i think i need to add it to the end of my move_uploaded_file but i could be wrong.

thanks

Re: Uploading images

Posted: Mon Jan 26, 2009 1:57 pm
by LiveFree
Look into using chown() http://www.php.net/chown and chgrp() http://www.php.net/chgrp

Re: Uploading images

Posted: Tue Jan 27, 2009 9:50 am
by QbertsBrother
thanks

i tried to use chown() and got this warning

Operation not permitted

my directory where i am uploading my images to is 777 when the file gets uploaded it has a owner and group of apache. would it not be the user apache that deletes the image as well?

one other thing is that when i use the terminal and view the files in the directory where i am uploading the images i see that the uploaded images look like this

Code: Select all

 
-rw-r--r-- 1 apache apache 327450 2009-01-27 09:31 anothertest27012009.jpg
but when i use a file browser and get the file info from there is says that the file has permissions of 444

safe mode is off