<?php
   function file_type(file){
       path_chunks = explode("/", file);
       thefile = path_chunks[count(path_chunks) - 1];
       dotpos = strrpos(thefile, ".");
       return strtolower(substr(thefile, dotpos + 1));
   }
   file_count = 0;
   path = "monthly/"; //the directory you want to use
   file_types = array('jpeg', 'jpg'); //the file types to show
   p = opendir(path);
       while (false !== (filename = readdir(p))) {
           files[] = filename;
       }
   sort(files);
       foreach (files as file) {
           extension = file_type(file);
           if(file != '.' && file != '..' && array_search(extension, file_types) !== false){
               file_count++;
               echo '<img src="'.path.file.'">'.'<br/>'; //在網頁上秀圖
           }
       }
    if(file_count == 0){
        echo "<b>No file match your file types</b>";
    }
?>
文章標籤
全站熱搜
創作者介紹
創作者 琉璃鯨魚 的頭像
琉璃鯨魚

琉璃鯨魚

琉璃鯨魚 發表在 痞客邦 留言(0) 人氣(78)