Forum Moderators: phranque
i'm uploading files to my server with this script:
if(!copy($_FILES['bestand']['tmp_name'], $HTTP_SERVER_VARS['DOCUMENT_ROOT']. "/usermade/" .$gamedir . "/images/".$bestandsnaam)) {
echo "Uploading failed. Please click the back button in the browser and try again.";
exit();
}
Problem is i can't delete these files after they have been uploaded. I get an access denied.
What could cause this and what could i do about this?
You already did without success the only thing I know to do....
okey i'm chmoding them 0777
they do get the chmod but i stell get denies acess.
777 is not a wise thing to do unless you really, REALLY REALLY need the files overwriteable. World-writeable means just that, anyone that can gain ownership permissions can overwrite them.
And that's what this is, an OWNERSHIP issue. Apache ownership is "anyone" but only "anyone" accessing the site through the web.
You are probably logging in as "domainowner" (i.e., whatever your FTP user name is.) While you can chmod the files as writable and have apache overwrite them, the inverse is not true. So one quick fix would be to upload the files and chmod them 777, which would allow apache to overwrite them, but it's not the wisest.
You could try using the same process as used by which they were created to delete them. If you create them using a script, delete them using a script.
Since i myself cannot acces the files while they are chmoded 777 how could someone else?
Also the upperlying directory is 777 also to allow creation of files by the php script.
Is there a better way to handle this?
And in what way does this compromise my security?
The reasons 777 is so risky can be explained better by the gurus, do a search for it. But the short answer is if someone gains access to a server via a script or other security hole - not necessarily via your site, it can be another domain on your hosting server - 777 gives them a place to do their dirty work.