apina Posted April 17, 2008 Share Posted April 17, 2008 Hi! I'd like to make a REALLY SIMPLE www gallery index page, that: - gets a list of subfolders and lists them on the page - gets a "folderdescription.txt" file from each directory and displays it's contents beneath each folder - shows a thumbnail for each folder (in each folder: folderthumbnail.jpg) Then, based on that info I quess I could write easily also the gallery code itself. So, I'd need a list of the subfolder names as some vector or something. That's what I don't know how to do... Just help with the PHP part is needed - I can handle the HTML... Link to comment https://forums.phpfreaks.com/topic/101530-making-a-list-of-folders/ Share on other sites More sharing options...
miracle_potential Posted April 17, 2008 Share Posted April 17, 2008 Assuming its one directory you want to open with your subdirectories in it. you shoul duse something like this. $dh = opendir($dirpath); while (false !== ($file = readdir($dh))) { if (!is_dir("$dirpath/$file")) { echo "<span class=maintxt>". str_replace("_"," ",$file) ."</span><br />"; echo "<a class=maintxt href="; echo $dirpath.$file; echo ">"; echo "Download This file"; echo "</a><br /><br />"; } } closedir($dh); Which loops and shows you all the files and all the folders and offers a download, not so sure about the thumbnails though not worked with pics all too much. Link to comment https://forums.phpfreaks.com/topic/101530-making-a-list-of-folders/#findComment-519335 Share on other sites More sharing options...
haku Posted April 17, 2008 Share Posted April 17, 2008 I'd like to make a REALLY SIMPLE www gallery index page, that: - gets a list of subfolders and lists them on the page - gets a "folderdescription.txt" file from each directory and displays it's contents beneath each folder - shows a thumbnail for each folder (in each folder: folderthumbnail.jpg) YOu basically have to pick - do you want a 'really simple' page, or do you want all that information? Its not the simplest deal to do what you speak of. Link to comment https://forums.phpfreaks.com/topic/101530-making-a-list-of-folders/#findComment-519367 Share on other sites More sharing options...
apina Posted April 17, 2008 Author Share Posted April 17, 2008 Thanks for the answer! I'll try that soon. I'm capable of programming complex things. It's just that I don't know the PHP commands & syntax for getting this file info - for example, if I just knew the names of the subdirectories, I can modify that code to make <img > tags of the thumbnails, links to the directories, and so on... Link to comment https://forums.phpfreaks.com/topic/101530-making-a-list-of-folders/#findComment-519459 Share on other sites More sharing options...
apina Posted April 17, 2008 Author Share Posted April 17, 2008 while (false !== ($file = readdir($dh))) Couldn't that be just "while( $file = readdir($dh) )" ? Link to comment https://forums.phpfreaks.com/topic/101530-making-a-list-of-folders/#findComment-519460 Share on other sites More sharing options...
Orio Posted April 17, 2008 Share Posted April 17, 2008 Yeah it's the same. Unless you got files/folders called "" or "0" or "false" etc' (without an extension). Orio. Link to comment https://forums.phpfreaks.com/topic/101530-making-a-list-of-folders/#findComment-519462 Share on other sites More sharing options...
apina Posted April 17, 2008 Author Share Posted April 17, 2008 Anyway, I think this first answer already answered my question - now I just have to experiment a bit with it Link to comment https://forums.phpfreaks.com/topic/101530-making-a-list-of-folders/#findComment-519463 Share on other sites More sharing options...
miracle_potential Posted April 17, 2008 Share Posted April 17, 2008 Hehe glad it was of some use I used it in an FTP application I programmed doing a very similar thing (except the thumbnail thing) Link to comment https://forums.phpfreaks.com/topic/101530-making-a-list-of-folders/#findComment-519475 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.