Jump to content

um is this possible....


BillyBoB

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
Link to comment
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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.