Listing files on the hard drive

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Bennettman
Forum Contributor
Posts: 130
Joined: Sat Jun 15, 2002 3:58 pm

Listing files on the hard drive

Post 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>");
}
}

?>
hedge
Forum Contributor
Posts: 234
Joined: Fri Aug 30, 2002 10:19 am
Location: Calgary, AB, Canada

Post 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.
Post Reply