Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've uploaded some files into a directory i've created (using a php upload script). At first I didn't set the right chmod for dir. and files (411 instead of 777). Now this folder and files are stuck on the server, can't delete using FTP, cant delete using script: unlink/rmdir. I don't have server acces. Is there any way to still do this using PHP scripting?

share|improve this question

migrated from Jun 9 '11 at 12:35

This question came from our site for professional and enthusiast programmers.

As long as you have created the directory you should be the owner and with 700 permission you can delete the directory (and the files in it) – VAShhh Jun 9 '11 at 9:57
Now the permissions are 411. I am sure they were 700 earlier... – tvgemert Jun 10 '11 at 9:51
But user and owner are the same: apache. When I upload files to a directory which is set to 775 (using the upload script) owner and user are also apache AND I'm able to delete them. So only difference are the permissions. – tvgemert Jun 10 '11 at 9:57
up vote 0 down vote accepted


chmod ("/somedir/somefile", 755); // php script code

does not work you still can try

unlink($filename);  // php script code


rmdir($dirname);  // php script code

to remove them. If this does not work then your apache-account on the server does not have the necessary rights to do that. I guess this should usually work cause your apache-account created those files.

share|improve this answer
I understand, and this should work. But not in this case. (see my comments on the original question) – tvgemert Jun 10 '11 at 11:24

There is PHP's chmod filesystem function, assuming PHP's process is the owner of dir, you can change permissions using it.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.