Page 1 of 1

PHP upload problem

Posted: Fri Jan 11, 2008 1:18 pm
by nikosb
I have a strange PHP problem when I try to upload an image.
I have a Unix Solaris server with multiple user accounts. I have a basic a html code

Code: Select all

<HTML>
  <BODY>

    <form enctype="multipart/form-data" action="testupload.php" method="POST">

      <input type="hidden" Name="MAX_FILE_SIZE" value="300000" />
      <input name="imgfile" Type="file" size="28" />&nbsp;&nbsp;
      <input type="SUBMIT" value="Upload" class="h11" />
  </form>
</BODY>

</HTML>
The testupload.php looks like this

Code: Select all

<?php
print_r($_FILES);
?>
When I test this script from one user account (corresponding to /home/user1/www/upload.html) the script works and files are uploaded to a temporary directory.

When I test the same script from the other user account (corresponding to /home/user2/www/upload.html) the script does not work. I get the following output

Code: Select all

Array
(
    [imgfile] => Array
        (
            [name] => winampmb.htm
            [type] => 
            [tmp_name] => 
            [error] => 6
            [size] => 0
        )

)
The error number 6 means that the upload directory is not defined. Why is this happening for user2 and not for user1 since both users are on the same server running the same version of php with the same user permissions?
I read through the php manual and there it explains that if the tmp upload directory is not defined in php.ini then php uses the default system directory. To make sure that there is a default system php dir I run the script from user1 and I find out that [imgfile][name] = /tmp/tmpname which means that the system temp upload directory is defined as /tmp. I also checked the permission of /tmp and they are drwxrwxrwt which I means that everybody should have write access to it, both "user1" and "user2" and "nobody"
I have spent a lot of time into this but I could not figure out a way to make the php upload work for user2. Can anybody give me some advice on what to look next? Is this possibly a PHP bug?

Thank you in advance,

Nikolaos

Re: PHP upload problem

Posted: Fri Jan 11, 2008 4:43 pm
by Christopher
It sounds like a permissions problem. The web server may not even have access to one of the parents of the target upload directory. Make sure the permissions are correct or create a directory somewhere where you can.

Re: PHP upload problem

Posted: Sat Jan 12, 2008 1:55 am
by Benjamin
This could be an SE Linux issue.

http://www.nsa.gov/selinux/