简体   繁体   中英

rmdir function not working on linux server

public function deleteAllEmailRelatedFolders($clientID) {


    $path = getcwd();
    //Delete Email Inbox Attachments
    $dir = $path . "\cdn\data\inbox/$clientID";

    //Delete Email Sent Attachments
    $dir2 = $path . "\cdn\data\sent/$clientID";

    var_dump($dir);
    var_dump($dir2);
    $this->rrmdir($dir);
    $this->rrmdir($dir2);
}

protected function rrmdir($dir) {
    if (is_dir($dir)) {
        $objects = scandir($dir);
        foreach ($objects as $object) {
            if ($object != "." && $object != "..") {
                if (filetype($dir . "/" . $object) == "dir")
                    $this->rrmdir($dir . "/" . $object);
                else
                    unlink($dir . "/" . $object);
            }
        }
        reset($objects);
        rmdir($dir);
    }
}

When i try to rmdir run on my linux.It does not works correctly.when i run it WAMP server in my localhost.It works perfectly.Please help me to solve this issue

As pointed out by shatheesh in a comment, your paths are incorrectly formatted for Linux.

Change your paths to:

//Delete Email Inbox Attachments
$dir = $path . "/cdn/data/inbox/$clientID";

//Delete Email Sent Attachments
$dir2 = $path . "/cdn/data/sent/$clientID";

More information about Linux directory paths and what they do is available at http://www.tecmint.com/linux-directory-structure-and-important-files-paths-explained/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM