A simple script that lists all the items in the directory including folders and files and even makes a link out of them. Its an all purpose script which you can use to do other things.
- //define the path as relative
- $path = "/home/yoursite/public_html/whatever";
- //using the opendir function
- echo "Directory Listing of $path<br/>";
- //running the while loop
- while ($file = readdir($dir_handle))
- //encode spaces
- $file = rawurlencode($file);
- // convert the + (this is one result from the function rawurlencode) in %20
- $url = str_replace('+' , '%20' , $file);
- echo "<a href='".$url."'>".$url."</a><br/>";
- //closing the directory
CommentsSubscribe to comments
You need to login to post a comment.