joefish Posted March 31, 2007 Share Posted March 31, 2007 I allowed a PHP script (plugin for WordPress) to create a directory. Now the directory is owned by a different user ID. I can't read from it, write to it or change permissions. I've tried using a simple PHP script to remove the directory (thinking if PHP created it, PHP can remove it), but that doesn't work. The part of the original script that created the directory is: >if ( !is_dir( ABSPATH . 'wp-content/backup-db' ) ) { mkdir( ABSPATH . 'wp-content/backup-db' ); } and the command I've tried to remove the directory is: >rmdir('/home/secret_name/public_html/blog/wp-content/backup-db'); But this returns the error: >Permission denied in /home/secret_name/public_html/blog/wp-content/New1.php on line 1 So. How can I remove this folder? Quote Link to comment Share on other sites More sharing options...
TCH-Don Posted March 31, 2007 Share Posted March 31, 2007 you can always open a help desk ticket to the techs if you can't get a script to work. Quote Link to comment Share on other sites More sharing options...
joefish Posted March 31, 2007 Author Share Posted March 31, 2007 you can always open a help desk ticket to the techsif you can't get a script to work. Understood, but if it's possible to resolve this myself, I'd like to. This issue pops up now and again among my TCH-using friends and I'd like to be able to offer a better solution than simply "the help desk can fix it." Quote Link to comment Share on other sites More sharing options...
TCH-Andy Posted March 31, 2007 Share Posted March 31, 2007 I just did a quick check in PHP, and you can remove the folder that way as long as you have permissions on that directory and it's parent directory. Quote Link to comment Share on other sites More sharing options...
TCH-Bruce Posted March 31, 2007 Share Posted March 31, 2007 Have you tried it like this? >exec("rm -r -f /home/secret_name/public_html/blog/wp-content/backup-db"); Quote Link to comment Share on other sites More sharing options...
joefish Posted March 31, 2007 Author Share Posted March 31, 2007 I just did a quick check in PHP, and you can remove the folder that way as long as you have permissions on that directory and it's parent directory. Oh, duh. I forgot to give appropriate permissions to the parent directory. Yeah, my first idea does work, so long as I give the parent of the folder to be removed temporarily higher permissions. Have you tried it like this? >exec("rm -r -f /home/secret_name/public_html/blog/wp-content/backup-db"); The rmdir() command worked just fine for me. I'll try this one next time I break something. Thanks, guys! Quote Link to comment Share on other sites More sharing options...
TCH-Bruce Posted March 31, 2007 Share Posted March 31, 2007 Glad you got it working. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.