PHP 讀取資料夾內容
<script language="javascript" type="text/javascript">
function ShowPic(p)
{
if(p!='Thumbs.db'){
document.getElementById("paint").innerHTML = '<img src="img/'+p+'" width="80px" height="40px" >';
document.getElementById("paint").style.display='block';
}
}
</script>
<?php
echo '<div class="PaintArea" id="paint" width="100px" height="50px" style="display:none;"></div>';
if ($handle = opendir('img/')) {
$num=0;
/* This is the correct way to loop over the directory. */
echo '<select id="pic_list" onchange="ShowPic(this.value);">';
while (false !== ($file = readdir($handle))) {
if($file !='.' && $file !='..' && $file!='Thumbs.db'){
echo '<option>'.$file.'</option>';
}
}
echo '</select>';
closedir($handle);
}
?>
