Let’s say that you want to add a file upload facility to your website via PHP. The key to this is to ensure that the permissions on the folder you are copying up to allow PHP to do the copying. This is a classic Gotcha that can waste a whole load of time.
The first thing you need to know is that the folder you’re copying up to must be “Owned” by “Apache” rather than the site owner. In other words, you need to set the permissions on the folder to be owned by Apache. This then leads onto the other question “what is the Apache OwnerID?”.
I spent a good couple of hours trying to find an answer to this question. The owner Id can be found in the configuration files but a MUCH easier way is to create a PHP file containing the line:
<?php
 echo phpinfo();
?>
Run this file in your browser, scroll down to the “apache2handler” section and you’ll see “User/Group” listed. The numbers next to this show first the OwnerId and then the GroupId (usually both the same). Use a tool such as BitVise Tunnelier to log into your web server and set the Owner and Group to this number and PHP will then be able to copy to that folder. Take care only to change ownership of those folders you specifically want to be able to upload files to.




.gif)