David David - 11 months ago 116
PHP Question

PHP's scandir() returns false, can't locate directory

I have a directory structure like this:

htdocs--->: dir.php,
img(rwxrw-rw-) ---> img1.jpg,

but when I try to use

in dir.php

it simply returns bool(false) and an error message saying it can't find /img/.

Why is this happening?

Answer Source

Unlikely /img directory exists since the leading / means it's at the root level of the hard drive. Try ./img The ./ means THIS directory, eg, the directory the currently running PHP script is in.