Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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 stackoverflow.com Jun 9 '11 at 12:35

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

1  
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
add comment

2 Answers

up vote 0 down vote accepted

If

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

does not work you still can try

unlink($filename);  // php script code

and

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
add comment

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
add comment

Your Answer

 
discard

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.