Re: [請益] 寫線上檔案總管遇到問題
目標:
我網頁每五秒會refresh一次
一但發現檔案數目有變動會出現一個警告視窗
我到我現在PO文為止所寫的程式碼為
//取得目前日期並顯示在瀏覽器上
echo "今天日期為 : 西元 ".date('Y')." 年 ,".date(m)."月 ".date(d)."日 ,禮拜 ".date(w);
echo "<br>";
echo "目前時間為 : ".date(A)." ".date(H)." 時 ".date(i)." 分 ".date(s)." 秒 ";/* 取得目前時間並顯示在瀏覽器上 */
$fd =opendir('.');
while($file = readdir($fd)):
$file_size=filesize($file);
$file_time=date("Y/m/d a h:i",filectime($file));//把Unix timestamp的時間,格式化成您熟習的日期格式
$filetable=array("filetime"=>array($file_time),
"filename"=>array($file),
"filesize"=>array($file_size));
echo "<tr bgcolor='White'><td>";
for($a=0; $a<count($filetable["filetime"]); $a++) {
echo $filetable["filetime"][$a]."</td>";
}
echo "<td align='right'>";
for($a=0; $a<count($filetable["filename"]); $a++){
echo $filetable["filename"][$a]."</td>";
}
echo "<td align='right'>";
for($a=0; $a<count($filetable["filesize"]); $a++){
echo $filetable["filesize"][$a]."</td>";
}
echo "<td align='center'><a href=" rel="nofollow">http://localhost/".$file.">瀏覽</td></tr>";
endwhile;
$filenumber=count($filetable["filename"]);
現在遇到第一個問題
我先把資料夾中的檔案資訊寫進一個陣列裡
檔案資訊可以全部被讀出到網頁上
但是在計算檔案個數上 怎麼算都是1...why??
第二個問題是 一開始在抓時間SHOW在網頁上那邊
用date(H)抓小時數總是早了整整八小時外 其他都正常
這又到底是為了什麼????
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 218.168.75.120
→
12/09 07:10, , 1F
12/09 07:10, 1F
→
12/10 23:30, , 2F
12/10 23:30, 2F
→
12/10 23:31, , 3F
12/10 23:31, 3F
討論串 (同標題文章)
PHP 近期熱門文章
PTT數位生活區 即時熱門文章