June 2, 2011

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);
   
}

?>

Today's Visitors: 0 Total Visitors: 0
Personal Category: Uncategorized Articles Topic: learning / education / linguistic
[Trackback URL]

Post A Comment









Yes No



Please input the magic number:

( Prevent the annoy garbage messages )
( What if you cannot see the numbers? )
Please input the magic number

誰來收藏
Loading ...
unlog_NVPO 0