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 Quote Link to comment 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. Quote Link to comment 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 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.