David David - 1 year ago 171
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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download