doufeixuan8882 2015-11-28 07:26
浏览 46

PHP无法删除文件内容

Can someone explain to me why I cannot delete the images that I was able to successfully import in the first half of the function

function delete_files($target) {
    foreach(glob($target.'*.*') as $v){
        unlink($v);
    }
}

function importImagesforSlideShow()
{
    $array = $_REQUEST["data"];
    $slidePath = '../../images/carousel-slides/';
    $url = $array[0];
    $images = $array[1];
    $imageExtQualifier = $array[2];

    if (!file_exists($slidePath)) {
        mkdir($slidePath, 0777, true);
    }

    foreach ($images as $imageName) {
        $context = stream_context_create(array(
            'http' => array(
                'ignore_errors' => true,
                'header' => "User-Agent:MyAgent/1.0
"
            )
        ));

        $urlLoc = $url . $imageName . $imageExtQualifier;
        $img = $imageName . '.jpg';
        file_put_contents($slidePath . $img, file_get_contents($urlLoc, FALSE, $context));
    }

    // not working
    delete_files(__DIR__ . $slidePath); 


    echo json_encode($images);
}

UPDATE:

Salty: I think you are on to something. This does nto look right

G:\PleskVhosts\abc.com\xyz.com\scripts\php../../images/carousel-slides/

it should be something like:

G:\PleskVhosts\abc.com\xyz.com\images/carousel-slides/

How to fix?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 素材场景中光线烘焙后灯光失效
    • ¥15 请教一下各位,为什么我这个没有实现模拟点击
    • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
    • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
    • ¥20 有关区间dp的问题求解
    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 slam rangenet++配置
    • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
    • ¥15 ubuntu子系统密码忘记
    • ¥15 保护模式-系统加载-段寄存器