Jump to content

Archived

This topic is now archived and is closed to further replies.

BillyBoB

um is this possible....

Recommended Posts

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/ dirctory

please 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

Share this post


Link to post
Share on other sites
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 HTML
echo $output;
?>
[/code]

Not sure if you wanted anything to be done when you select an item from the dropdown.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.