有人可以向我解释为什么我无法删除我能够在功能的前半部分成功导入的图像
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\r\n"
)
));
$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);
}
更新
咸:我认为你有所作为。这看起来不错G:\ PleskVhosts \ abc.com \ xyz.com \脚本\ PHP ../../图像/转盘-幻灯片/
应该是这样的:
G:\ PleskVhosts \ abc.com \ xyz.com \图像/转盘-幻灯片/
如何解决?