Hey everyone, Im looking php which will populate a dropdown list with the contents of my Images Folder for my Backend.
Could Someone Please Advise Me On This Task?
Hope you can Help, Paul
[code=php] <? $path = "."; //change this if the script is in a different dir that the files you want $show = array( '.jpg', '.gif', '.png' ); //Type of files to show $select = "<select name="select_box">"; $dh = @opendir( $path ); while( false !== ( $file = readdir( $dh ) ) ){ $ext=substr($file,-4,4); if(in_array( $ext, $show )){ $select .= "<option value='$path/$file'>$file</option>n"; } } $select .= "</select>"; closedir( $dh ); echo "$select"; ?> [/code]
Help @Donno24 spread the word by sharing this article on Twitter...