Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/159.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
php无法删除图像_Php_Filesystems_Delete File - Fatal编程技术网

php无法删除图像

php无法删除图像,php,filesystems,delete-file,Php,Filesystems,Delete File,我有以下代码从我的网站上删除帖子。此功能适用于视频帖子,可完美删除视频帖子。但它不适用于图片帖子,也不会从web目录中删除帖子图片。我的代码是 function delete_post($id, $fromStory = false) { $post = get_post($id); if ($fromStory and !$post['is_story']) return true; if (!$fromStory and !can_edit_post($post))

我有以下代码从我的网站上删除帖子。此功能适用于视频帖子,可完美删除视频帖子。但它不适用于图片帖子,也不会从web目录中删除帖子图片。我的代码是

function delete_post($id, $fromStory = false) {
    $post = get_post($id);
    if ($fromStory and !$post['is_story']) return true;
    if (!$fromStory and !can_edit_post($post)) return false;
    if ($post['images']) {
        $images = perfectUnserialize($post['images']);
        if($images) {
            foreach($images as $image) {
                delete_file(path($image));
            }
        }

        if ($post['video']) {
            delete_file(path($post['video']));
        }
}
此外,我还删除了下面给出的旧故事功能

function delete_old_stories() {
    $time = time() - (3600 * config('story-deleted-at', 24));
    $query = db()->query("SELECT id,post_id FROM story_posts WHERE time_created < $time ");
    while($fetch = $query->fetch(PDO::FETCH_ASSOC)) {
        db()->query("DELETE FROM story_posts WHERE id=?", $fetch['id']); //delete story posts
        delete_post($fetch['post_id'], true);
    }
    return true;
}
对于每个故事,目录中的图像文件是

_1000_8f81946314be5cfe962480b96c7df11e.jpg
对于Post,目录中的图像文件是

_1000_8f81946314be5cfe962480b96c7df11e.jpg
_600_8f81946314be5cfe962480b96c7df11e.jpg

“删除故事”功能正常,它可以删除故事图像,但“删除帖子”不会删除图像。

是否检查了“帖子”文件夹的权限?文件夹权限为755,我也尝试了777。此外,故事图片已从同一文件夹中删除,因此文件夹权限不应存在任何问题。
_1000_8f81946314be5cfe962480b96c7df11e.jpg
_600_8f81946314be5cfe962480b96c7df11e.jpg