BoltZ Posted November 1, 2008 Share Posted November 1, 2008 I need someone to tell me how to change the permissions of several folders in my cpanel from 755 to 777 and how to delete a folder entirely The problem is with my forum script installation i am writing i realized that the files have to be 777 to work so i need help with it. Quote Link to comment https://forums.phpfreaks.com/topic/130965-changing-file-permissions-advanced/ Share on other sites More sharing options...
genericnumber1 Posted November 1, 2008 Share Posted November 1, 2008 Simple enough: Change file permissions... http://us.php.net/chmod Delete directories... http://us.php.net/rmdir Or you could use the command line through php and do it that way if you really want to. Quote Link to comment https://forums.phpfreaks.com/topic/130965-changing-file-permissions-advanced/#findComment-679858 Share on other sites More sharing options...
BoltZ Posted November 1, 2008 Author Share Posted November 1, 2008 Ok thanks Ill check it out but i'll probably have problems with my code Quote Link to comment https://forums.phpfreaks.com/topic/130965-changing-file-permissions-advanced/#findComment-679862 Share on other sites More sharing options...
genericnumber1 Posted November 1, 2008 Share Posted November 1, 2008 post any questions here and I'd be glad to help if I'm still awake. Quote Link to comment https://forums.phpfreaks.com/topic/130965-changing-file-permissions-advanced/#findComment-679865 Share on other sites More sharing options...
BoltZ Posted November 1, 2008 Author Share Posted November 1, 2008 Ok I have it on the pgae after the sql is done that there is a button in the form tag which is here <form action="delete.php"> <input type="button" value="Delete Install Directory" name="delete" /> </form> and when they click that it goes to delete.php and this is the code i have in there but I dunno why it wont owrk, it literally doen't do anything on the page. go to my forum site and see for yourself <?php rmdir('/install'); Header('Location: ../index.php'); ?> Quote Link to comment https://forums.phpfreaks.com/topic/130965-changing-file-permissions-advanced/#findComment-679870 Share on other sites More sharing options...
genericnumber1 Posted November 1, 2008 Share Posted November 1, 2008 rmdir() can only delete directories that are empty. I made this recursive dir deleting script for a different thread, but it should work out okay. <?php function rmDirRecursive($dir) { if($dir[strlen($dir)-1] != DIRECTORY_SEPARATOR) { $dir .= DIRECTORY_SEPARATOR; } if(is_dir($dir)) { $dh = opendir($dir); while(($file = readdir($dh)) !== false && $file != '.' && $file !='..') { if(is_dir($file)) { rmDirRecursive($dir . $file); } else { unlink($dir . $file); } } rmdir($dir); } } ?> as I told that person... I haven't tested this function, so you will want to do that. Quote Link to comment https://forums.phpfreaks.com/topic/130965-changing-file-permissions-advanced/#findComment-680037 Share on other sites More sharing options...
BoltZ Posted November 1, 2008 Author Share Posted November 1, 2008 Will this code delete the entire directory no matter what? Also I think you should note that the file that when the person clicks this button for the action is in fact in the directory that I want to delete lol. Quote Link to comment https://forums.phpfreaks.com/topic/130965-changing-file-permissions-advanced/#findComment-680058 Share on other sites More sharing options...
genericnumber1 Posted November 1, 2008 Share Posted November 1, 2008 that script will loop through the contents of the directory passed, if it finds a file, it deletes it, if it finds another dir, it will loop through the contents of that dir... repeating this pattern until all files are deleted, then it deletes the directory passed. it WON'T delete it if php doesn't have permission in the operating system to do so... Quote Link to comment https://forums.phpfreaks.com/topic/130965-changing-file-permissions-advanced/#findComment-680073 Share on other sites More sharing options...
BoltZ Posted November 1, 2008 Author Share Posted November 1, 2008 Well why shouldnt it have the permissions? Quote Link to comment https://forums.phpfreaks.com/topic/130965-changing-file-permissions-advanced/#findComment-680082 Share on other sites More sharing options...
genericnumber1 Posted November 1, 2008 Share Posted November 1, 2008 There are unlimited reasons it wouldn't have the permissions, I can't really answer that question. Quote Link to comment https://forums.phpfreaks.com/topic/130965-changing-file-permissions-advanced/#findComment-680086 Share on other sites More sharing options...
BoltZ Posted November 1, 2008 Author Share Posted November 1, 2008 ok well it might be a couple days before im ready for this because if i test this now then all my files will be gone. I have to finish the instlalation code then back it up then i can try this out. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/130965-changing-file-permissions-advanced/#findComment-680089 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.