Click to See Complete Forum and Search --> : Privelages for move_uploaded_file(); ?
Stephen Philbin
02-13-2005, 10:38 AM
Hi folks. Just been experimenting with file uploading via php and I've come accross an error which I found to be a bit of a suprise. move_uploaded_file(); failed with failed to open stream: Permission denied in /dootserv/htdocs/admin/acpp1.php
I thought that apache and php both ran as root? If so, how on earth can they have insufficient privileges?
AdamGundry
02-13-2005, 02:06 PM
I thought that apache and php both ran as root?[/B]It would be a massive security mistake if they did. On most systems I've seen, Apache has its own user (normally called apache) and group (often also apache). PHP runs under the privileges of the web server IIRC.
So yes, if the directory move_uploaded_file() is trying to write to is not writable by the apache user, it will fail. Either change its privileges to world-writable, or transfer ownership to the apache user. (Comprimise: transfer it to the apache group and make it group-writable.)
Adam
Stephen Philbin
02-13-2005, 02:43 PM
Nice one adam. Yoo arrrrr teh zooper star. :D
I'll have a poke around now and see if I can persuade my directories into playing nice. :D