Re: Permission denied when executing 'copy' command in a PHP script
| From: | Edward Diener | Date: | Mon, 15 Sep 2008 21:33:09 +0000 |
| Subject: | Re: Permission denied when executing 'copy' command in a PHP script | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-280219@lists.php.net to get a copy of this message | ||
Thiago H. Pojda wrote:
On 9/15/08, Edward Diener <eldiener@tropicsoft.com> wrote:Does the error message mean that access is denied in the 'from' file ( $_FILES['HtmlFile']['tmp_name'] ) or the 'to' location ( aplace/ahtml.html ) ?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 !
Did you check file/dir permissions? Has anything changed? Your sysadmin could have changed the user running apache or dir perms.What is the 'user running Apache' and how do I determine it ? The 'to' directory has a Linux permission of 755. The PHP script has a permission setting of 644.