[請益] 寫線上檔案總管遇到問題
我網頁每五秒會refresh一次
一但發現檔案數目有變動會出現一個警告視窗
現在我該如何做到發現檔案數目變動???
以下為我目前的寫的程式碼
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=big5">
<meta http-equiv="refresh" content="5"><!--每5秒自動刷新 -->
<title>
Home Survieliance
</title>
</head>
<body>
<div align="center">
<h1>XXXXXXXXXX</h1>
</div>
<hr>
<table " border="0" cellspacing="1" cellpadding="2" bgcolor="Silver"><tr>
<td colspan="5" bgcolor="Navy">
<font color="White">線上檔案總管</font>
</td></tr>
<tr bgcolor="#D7D7D7">
<td width="150" align="center">檔名</td>
<td width="120" align="center">大小 (byte)</td>
<td width="200" align="center">修改日期</td>
<td width="80" align="center"></td></tr>
<?php
//取得目前日期並顯示在瀏覽器上
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("filename"=>array($file),
"filesize"=>array($file_size),
"filetime"=>array($file_time));
echo "<tr bgcolor='White'><td>";
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='right'>";
for($a=0; $a<count($filetable["filetime"]); $a++){
echo $filetable["filetime"][$a]."</td>";
}
echo "<td align=center><a href=" rel="nofollow">http://localhost/".$file.">瀏覽</td></tr>";
endwhile;
closedir($fd);
?>
</body>
</html>
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 61.224.91.252
※ 編輯: aaronsoso 來自: 61.224.91.252 (11/28 00:40)
推
11/28 10:36, , 1F
11/28 10:36, 1F
推
11/28 11:56, , 2F
11/28 11:56, 2F
推
11/28 12:26, , 3F
11/28 12:26, 3F
討論串 (同標題文章)
PHP 近期熱門文章
PTT數位生活區 即時熱門文章