开发者

Files won't delete

开发者 https://www.devze.com 2023-02-04 11:02 出处:网络
I ran chown -R www-data:www-data /srv/www/dev.example.com/public_html/uploads/ didn\'t work Tried chmod 777 didn\'t work.

I ran chown -R www-data:www-data /srv/www/dev.example.com/public_html/uploads/ didn't work Tried chmod 777 didn't work.

define('UPLOADPATH', "/srv/www/dev.example.com/public_html/uploads/members/");
$userId = 6;
$dir = UPLOADPATH . $userId;
rmdir($dir);

isn't removing the users folder(This runs to wipe out all their files, when deleting account). also(To delete just one photo)

 $RemovePreview = UPLOADPATH . $userId. '/' . $file . '_preview.' . $image_ending;
                        if (file_exists($RemovePreview))
                        {
                            @unlink($RemovePreview);
                        }

file and image_ending are coming from my Database. Also won't delete the file.

I really don't k开发者_运维知识库now whats up. Not sure if this is a Php, Server or both issue?


Is your directory empty? The Documentation to rmdir says that the directory needs to be empty; what you might be looking for is a recursive version of rmdir:

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


Use sudo when you try chown or chmod on files or directory you don't own.

0

精彩评论

暂无评论...
验证码 换一张
取 消