bubbasheeko Posted March 11, 2009 Share Posted March 11, 2009 I am trying to come up with an easy way for a client to update their image gallery and came up with an idea....the problem? Inexperience with file commands for php... Here is the idea. A folder is set up for the user - /photos/ They will create new directories - used as categories. Under each directory (category) they will upload images related to the directory name. The site visitor will see a thumbnail of the first image in the directory acting as an 'icon'. If they click on it they will then be able to see a thumbnails of each image under that directory. They will be able to click on it and it will show up on screen. Can anybody provide me with direction?? Quote Link to comment Share on other sites More sharing options...
bubbasheeko Posted March 11, 2009 Author Share Posted March 11, 2009 Okay...did some playing while I have been waiting I came up with this... <?php if(isset($_GET['d'])) { $path = "../photos/" . $_GET['d'] . "/"; $imgDir = opendir($path); } else { $path = "../photos/"; $imgDir = opendir($path); } while($imgName = readdir($imgDir)) { if(is_dir($path . $imgName)) { if (($imgName != ".") && ($imgName != "..")) { echo "<a href=\"photo_test.php?d=" . $imgName . "\">". $imgName ."</a><br />"; } } else { if (($imgName != ".") && ($imgName != "..")) { echo '<a href="' . $path . $imgName . '">' . $imgName . '</a><br />'; } } } ?> Not sure if this is the right way, but it does work I have separated the directories because I am going to be adding a nice listing using thumbnails...so I will see how that goes. Quote Link to comment Share on other sites More sharing options...
bubbasheeko Posted March 11, 2009 Author Share Posted March 11, 2009 Okay....massive misfire of the brain...I think I am a victim of if statements. I want to throw the directories and the files in a table with 5 columns...how would I do that with what I have come up with??? Quote Link to comment Share on other sites More sharing options...
bubbasheeko Posted March 11, 2009 Author Share Posted March 11, 2009 hmm..I don't give myself enough credit..... <?php if(isset($_GET['d'])) { $path = "../photos/" . $_GET['d'] . "/"; $imgDir = opendir($path); } else { $path = "../photos/"; $imgDir = opendir($path); } echo "<table width='600' colspan='2' rowspan='2' align='center'>"; $i=0; // COUNTER FOR TABLE BUILDER while($imgName = readdir($imgDir)) { $i++; if($i == 1) { echo "<tr>"; } elseif($i == 6) { echo "</tr><tr>"; $i = 0; } if(is_dir($path . $imgName)) { if (($imgName != ".") && ($imgName != "..")) { echo '<td><a href="photo_test.php?d=' . $imgName . '"><img src="../images/PictureFolder.jpg" border="0"><br />' . $imgName . '</a></td>'; } } else { if (($imgName != ".") && ($imgName != "..")) { echo '<td><a href="' . $path . $imgName . '">' . $imgName . '</a></td>'; } } } echo "</tr></table>"; ?> Again...it may not be perfect...but it works Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.