Re: Permission denied when executing 'copy' command in a PHPscript

From: Date: Mon, 15 Sep 2008 21:47:43 +0000
Subject: Re: Permission denied when executing 'copy' command in a PHPscript
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-280224@lists.php.net to get a copy of this message
b wrote:
Edward Diener wrote:
In a PHP file upload script which looks like: $htmlplace="aplace"; if ($_FILES['HtmlFile']['name'] != "") {
    $filenamex = basename($_FILES['HtmlFile']['name']);
    copy($_FILES['HtmlFile']['tmp_name'],$htmlplace."/".$filenamex);
}
You should take a look at is_uploaded_file() and move_uploaded_file().
OK, thanks for pointing this out.
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 !
It means that the web server has been denied permission by the OS. Check that the directory perms are properly set.
The directory perms of the 'to' directory ? It is 755.
You might also want to use a full directory path (ie. from the root of the server) for the location the file should be saved to.
I do not think I can know this from my PHP script.

« previous php.general (#280224) next »