Trying to get scandir() working and need a little help…
I’m able to get scandir() to work when the $dir is a subdirectory or the current scripts location however im trying to access a folder elsewhere on the server but when I try to locate it using a URL i’m getting errors…
Script location – http://mysite.com/scripts/getFileNames.php
Directory Location – http://mysite.com/images/thumbnails
<?php $dir = 'ResourceImages/Previews/1'; $files1 = scandir($dir); print_r($files1); ?>
You can’t use external URLs with scandir().
Try using the full path on the server to retrieve the files.
Thanks for that, managed to get it working on localhost with…
<?php $dir = $_SERVER['DOCUMENT_ROOT']; $dir .= '/SITE-DEBUG/Images/Previews/1'; $files = array_diff(scandir($dir), array('..', '.')); print_r($files); ?>