Re: Permission denied when executing 'copy' command in a PHPscript
| From: | Edward Diener | Date: | Mon, 15 Sep 2008 21:42:04 +0000 |
| Subject: | Re: Permission denied when executing 'copy' command in a PHPscript | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-280222@lists.php.net to get a copy of this message | ||
Thodoris wrote:
On 9/15/08, Edward Diener <eldiener@tropicsoft.com> wrote:The server is under Linux running Apache.If you are using unix along with apache web server you need to find out what is the user that you are running your server as. I am pretty sure that www-data is not the default user at least not in the unix like OSes I use. Any distro uses it's own ways as far as I know and BSD has it's own paths as well.In a PHP file upload script which looks like: $htmlplace="aplace"; if ($_FILES['HtmlFile']['name'] != "") {Apache - or your http process - process (default www-data in *nix) has to have access to the file/dir in order to copy it.$filenamex = basename($_FILES['HtmlFile']['name']); copy($_FILES['HtmlFile']['tmp_name'],$htmlplace."/".$filenamex);} I am getting the error message: <br /> <b>Warning</b>: copy(aplace/ahtml.html) [<a href='function.copy'>function.copy</a>]: failed to open stream: Permission denied in <b>/home/directory/anotherdirectory/makecopy2.php</b> on line <b>6</b><br /> This was working perfectly before so I am at a loss as to why it is now failing. Does anybody have any idea what could be happening and what the Permission denied refers to and means ? Thanks !
Where is the httpd.conf located ? I do not seem to have any access to it on the server.Did you check file/dir permissions? Has anything changed? Your sysadmin could have changed the user running apache or dir perms. Regards,You can find what is this user that you run apache with in your httpd.conf in a place there where there is something like "User apache".
This user should exist and have write and exec acces to the directory you need to write the file.Is the the 'to' directory for which access has been denied or is it the temporary 'from' directory which can not be accessed ?