Fontayne56 Posted April 30, 2009 Posted April 30, 2009 Hi all hope you can help I'm wanting to read content from a folder and display this on a webpage. Thus when we have letters home ect parents are able to download them !! and dont need to keep updating the website. I use to do this on my old school webpage but for the life of me could'nt work out how i done it. Any ideas Thank You !!
theriver Posted April 30, 2009 Posted April 30, 2009 Hi Are you talking about directory browsing, e.g. IIS Directory Browsing
tomdawson Posted May 13, 2009 Posted May 13, 2009 If you've got PHP available on your web server, just bung this into an index.php file: $path = "./"; $dir_handle = @opendir($path) or die("Unable to open $path"); while (false !== ($file = readdir($dir_handle))) { if($file == "index.php") continue; echo "$file "; } closedir($dir_handle); ?> Will list everything in that directory (except the index.php file) and create a link to it 1
Fontayne56 Posted May 13, 2009 Author Posted May 13, 2009 This Worked a treat. Stick it with a style sheet bobs your uncle !! THANKS A BUNCH !! he he ! (one happy man)
tomdawson Posted May 17, 2009 Posted May 17, 2009 This Worked a treat. Stick it with a style sheet bobs your uncle !! THANKS A BUNCH !! he he ! (one happy man) Hehe, glad I could be of assistance!
Fontayne56 Posted December 7, 2009 Author Posted December 7, 2009 Been having another play and now i would like to read a different folder where the php page does'nt sit. I can get them to list contence of another folder but i can seem to get the folder name into the url so the file will open. Elp <?php $path = "./graphics"; $dir_handle = @opendir($path) or die("Unable to open $path"); while (false !== ($file = readdir($dir_handle))) { if($file == "index.php") continue; echo "$file"; } closedir($dir_handle); ?> Many Thanks
Willott Posted December 7, 2009 Posted December 7, 2009 I would think the following should do it: echo "$file "; } The readdir will dump out to names within that directory, but won't put the path in.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now