NYCPHP Meetup

NYPHP.org

[nycphp-talk] File uploading: When PHP doesn't have permission to

Dan Cech dcech at phpwerx.net
Sat Jan 3 00:13:43 EST 2004


It sounds like you do have a permissions problem.

You will need to make sure that the webserver process (usually www-data 
for apache) has permissions to write to the directory where you want to 
put the uploaded file.

A simple test is to create a new directory and set permissions to 
rwxrwxrwx (chmod 777), then try to move the file there.  If it works 
then you know what your problem is.

As for fixing the permissions, you are going to have to figure out a 
setting which gives the webserver the access it needs, without causing 
any security problems.  There are several different ways to do it, one 
method is to set the group of the directory to www-data and use the 
group permission setting to control the access you want to give to php.

Hope this helps,

Dan

Webapprentice . wrote:
> Hi,
> I was trying to use the file uploading aspect of PHP.
> 
> When I tried to execute this line
> move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadFile)
> 
> I get a permission denied error.
> 
> $_FILES['userfile']['errors'] is equal to 0, which indicates the file was uploaded to the temp directory of the host, so I think it either couldn't copy it to where I wanted (my user directory) or copy out of the tmp directory.  Running phpinfo() in my user directory indicates that file_uploads is ON and safe_mode is OFF on the server.
> 
> I don't own the server, so I don't think I can give PHP permission, or can I?
> 
> Do I have any way around this?
> 
> Thanks,
> Stephen




More information about the talk mailing list