Jump to content


Photo

um is this possible....


  • Please log in to reply
2 replies to this topic

#1 BillyBoB

BillyBoB
  • Members
  • PipPipPip
  • Advanced Member
  • 630 posts

Posted 13 August 2006 - 07:13 AM

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:

http://dreamshowstud...c.php?pic=pic-1

this isnt the drop down box this is just the pic and another feature

#2 Prismatic

Prismatic
  • Members
  • PipPipPip
  • Advanced Member
  • 503 posts
  • LocationSan Diego

Posted 13 August 2006 - 07:37 AM

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.

 <?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;
?>

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

#3 BillyBoB

BillyBoB
  • Members
  • PipPipPip
  • Advanced Member
  • 630 posts

Posted 13 August 2006 - 07:45 AM

i found somthing simular and i like it but thanks tho




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users