I have a folder called images
in my current directory but when I try to run the code below I get the following error:
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);
I've tried every variation of the path I can think of ( images, /images/, "images", 'images'
etc. but no joy.
var_dump (is_dir('/images'));
also gives false
Please help?
尝试使用__DIR__
常量
$dir = __DIR__ . "/images";
I think your $dir is not correct.you can use
$dir = __DIR__ . "/images";
or
$dir = "./images";
Both are working. If its not working show me your image folder structure.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.