Page 1 of 1

Listing files on the hard drive

Posted: Fri Dec 27, 2002 8:23 pm
by Bennettman
I'm trying to code a PHP page so I can view the images in folders on my hard drive. It's a simple idea that the $folder value is specified in the URL, and it works fine for files online but I don't know how to set the root to look in the C: drive. Any help?

Code: Select all

<?php

$root = ("image_folder");

if ($value = opendir("$root/$folder")) {
while (false !== ($file = readdir($value))) { 
print ("<img src="$root/$folder/$file"><br>");
}
}

?>

Posted: Fri Dec 27, 2002 9:46 pm
by hedge
If you mean to provide a directory listing of the person browsing the site then, no that's not possible. PHP is server side, the only hard drive it can see is the webserver it is running on.