PHP scandir 不适用于相对路径
PHP scandir not working for relative path
我的当前目录中有一个名为 images
的文件夹,但是当我尝试 运行 下面的代码时,出现以下错误:
PHP Warning: scandir(../images,../images): The system cannot find the file specified. (code: 2) in C:\Program Files (x86)\Ampps\www\dev\php\recolor_png\dir.php on line 4
<?php
$dir = "../images";
$a = scandir($dir);
print_r($a);
我已经尝试了所有我能想到的路径变化(images, /images/, "images", 'images'
等等,但没有任何乐趣。
var_dump (is_dir('/images'));
也给出 false
请帮忙?
尝试使用__DIR__
常量
$dir = __DIR__ . "/images";
我认为你的 $dir 不是 correct.you 可以使用
$dir = __DIR__ . "/images";
或
$dir = "./images";
两者都在工作。如果它不起作用,请告诉我你的图像文件夹结构。
我的当前目录中有一个名为 images
的文件夹,但是当我尝试 运行 下面的代码时,出现以下错误:
PHP Warning: scandir(../images,../images): The system cannot find the file specified. (code: 2) in C:\Program Files (x86)\Ampps\www\dev\php\recolor_png\dir.php on line 4
<?php
$dir = "../images";
$a = scandir($dir);
print_r($a);
我已经尝试了所有我能想到的路径变化(images, /images/, "images", 'images'
等等,但没有任何乐趣。
var_dump (is_dir('/images'));
也给出 false
请帮忙?
尝试使用__DIR__
常量
$dir = __DIR__ . "/images";
我认为你的 $dir 不是 correct.you 可以使用
$dir = __DIR__ . "/images";
或
$dir = "./images";
两者都在工作。如果它不起作用,请告诉我你的图像文件夹结构。