Ashley Sheridan wrote:
On Mon, 2008-09-15 at 17:33 -0400, Edward Diener wrote:
Thiago H. Pojda wrote:
On 9/15/08, Edward Diener <eldiener@xxxxxxxxxxxxxx> 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);
}
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 !
Apache - or your http process - process (default www-data in *nix) has to
have access to the file/dir in order to copy it.
Does the error message mean that access is denied in the 'from' file (
$_FILES['HtmlFile']['tmp_name'] ) or the 'to' location (
aplace/ahtml.html ) ?
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.
To determine what user Apache is running in, at the command line (open a
terminal window or something) and type "ps -e" without the quotes. You
should see a couple of entries either for Apache or httpd which is the
web server.
This is a web hosting site of my employer, so I do not have direct
access to logon to the server. There is a set of PHP scripts which
represent a limited access to files, but nothing which lets me logon to
the Linux box.
If you are getting an access denied message on an uploaded file, it's
likely that you don't have write permissions to the actual directory you
are trying to copy the file to. Make sure it has write permissions for
the Apache user; just make the Apache user the owner of the directory,
and do a chmod 755 to it.
I have talked to my employer who will talk to the web host. The PHP
scripts which provide limited access allow one to change the Linux
permissions for a directory but do not allow one to change the owner of
the directory.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php