Uploading images

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
QbertsBrother
Forum Commoner
Posts: 58
Joined: Thu Oct 11, 2007 10:12 am

Uploading images

Post 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
LiveFree
Forum Contributor
Posts: 258
Joined: Tue Dec 06, 2005 5:34 pm
Location: W-Town

Re: Uploading images

Post by LiveFree »

Look into using chown() http://www.php.net/chown and chgrp() http://www.php.net/chgrp
QbertsBrother
Forum Commoner
Posts: 58
Joined: Thu Oct 11, 2007 10:12 am

Re: Uploading images

Post 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
Post Reply