BillyBoB Posted August 13, 2006 Share Posted August 13, 2006 can i make a drop down list that has files that are in a directory ? i have halo 2 pics from in game and i want to make a drop down box to show all the pics in the halopics/ dirctoryplease help heres wat i have so far:[url=http://dreamshowstudios.net/viewpic.php?pic=pic-1]http://dreamshowstudios.net/viewpic.php?pic=pic-1[/url]this isnt the drop down box this is just the pic and another feature Link to comment https://forums.phpfreaks.com/topic/17391-um-is-this-possible/ Share on other sites More sharing options...
Prismatic Posted August 13, 2006 Share Posted August 13, 2006 This works for me to show the images in a directory as a dropdown. Make sure to edit the $direc variable to fit your needs.[code] <?php//Images to ignore, File name ONLY, no extension, seperate by a comma, no spaces//Example: $ignoreimages = "BlahImage,ImageMeh";$ignoreimages = "";$direc = "c:/wamp/www/mysite/webicons/halopics/";$dh = opendir($direc);while (false !== ($filename = readdir($dh))) { $files[] = $filename;}$output .= "<form name='FileList' method='post' action=''> <select name='select'>";//Accepted File Types To display$acceptedfiles = array(1 => "jpg", 2 => "png", 3 => "gif");//Build the array that holds the files to exclude.$ignore = explode(",", $ignoreimages);$FileCount = count($files);for($i=0; $i <= $FileCount; $i++){ $file1 = explode(".", $files[$i]); $blah = count(file1); $extension = $file1[$blah]; $filename = $file1[$blah -1]; if(in_array($extension, $acceptedfiles)) { if(!in_array($filename, $ignore)){ $output .= "<option value='". $files[$i] ."'>". $files[$i] ."</option>"; } }}//Close the file out$output .= "</select> </form>";//output the HTMLecho $output;?>[/code]Not sure if you wanted anything to be done when you select an item from the dropdown. Link to comment https://forums.phpfreaks.com/topic/17391-um-is-this-possible/#findComment-73982 Share on other sites More sharing options...
BillyBoB Posted August 13, 2006 Author Share Posted August 13, 2006 i found somthing simular and i like it but thanks tho Link to comment https://forums.phpfreaks.com/topic/17391-um-is-this-possible/#findComment-73985 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.