Jump to content

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/130965-changing-file-permissions-advanced/
Share on other sites

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');
?>

 

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.

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...

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.