View Full Version : Read dir and sub-dir and put image in dropdown box

07-17-2007, 12:28 AM
Good day to you all,
I have searched , tried, many way but I can't figure how to make that piece of code look into all the sub-folder and take show all image file in a drop down box.

<script language="JavaScript" type="text/javascript" >
function changePic(fe){
var opt_key = fe.selectedIndex;
var fileName = fe.options[opt_key].value;
return true;
<select name="image" onchange="changePic(this);">
<option>[Choisir une image]</option>
function PGL_ConfigList($dir)
$files = array();
if($open = opendir($dir))
while(false !== ($file = readdir($open)))
if(eregi($pattern, $file) && !is_dir($file))
$files[] = $file;

$dir = "Upload/";
$list = PGL_ConfigList($dir);
foreach($list AS $file)
echo "<option value=\"Upload/$file\">$file</option>";
echo "</select>";

Can somebody help me with this ?
I'm on php 4, on window 2003

07-17-2007, 10:25 AM
works fine for me - what is the problem? Are you getting an error of some sorts? Perhaps the problem is the directory that you're giving it.

07-17-2007, 01:53 PM
Yes it's working fine, I need it to look into that same directory and his sub-directory to find all the images within the folder and his sub folder.

07-17-2007, 01:58 PM
I see, well this should be what you're looking for then