简体   繁体   English

rmdir函数在Linux服务器上不起作用

[英]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 当我尝试在Linux上运行rmdir时,它无法正常运行。当我在本地主机中运行WAMP服务器时,它可以正常运行。请帮助我解决此问题

As pointed out by shatheesh in a comment, your paths are incorrectly formatted for Linux. 正如shatheesh在评论中指出的那样,您的路径在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/ 有关Linux目录路径及其作用的更多信息, 请参见http://www.tecmint.com/linux-directory-structure-and-important-files-paths-explained/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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