[PHP] - สอบถาม Automatic refresh page
ถาม-ตอบ แนะนำไอเดียว โค้ดตัวอย่าง แนวทาง วิธีแก้ปัญหา [PHP] - สอบถาม Automatic refresh page
[PHP] - สอบถาม Automatic refresh page
Copy
ปัญหาคือในโฟลเดอร์ มีภาพ 001.jpg และ echo 001.jpg แล้วเพิ่มภาพ 002.jpg
หน้า index.php จะให้แสดงภาพ 002.jpg ได้ยังไงครับ
ขอบคุณครับ
ผมก็ไปค้นหาเจอข้อมูลที่หน้าจะคล้ายสุด แต่นำไปเทสแล้ว ไม่สามารถ echo ภาพ 002.jpg ได้
https://stackoverflow.com/questions/42928102/php-automatically-refresh-page-if-the-content-of-a-specific-file-has-changed
-The content of "index.php":
หน้า index.php จะให้แสดงภาพ 002.jpg ได้ยังไงครับ
ขอบคุณครับ
ผมก็ไปค้นหาเจอข้อมูลที่หน้าจะคล้ายสุด แต่นำไปเทสแล้ว ไม่สามารถ echo ภาพ 002.jpg ได้
https://stackoverflow.com/questions/42928102/php-automatically-refresh-page-if-the-content-of-a-specific-file-has-changed
-The content of "index.php":
<script language="javascript">
//var myVar=setInterval(function(){chekUpdate()},5*60*1000); // at 5 minutes intervals
var myVar=setInterval(function(){chekUpdate()},1000);
var stat_old = "";
function chekUpdate()
{
$("#status_fisier").load("check_file_stat.php",function(){
var stat_new = $("#status_fisier").html();
if((stat_old != "") && (stat_old != stat_new)){
refreshSlideShow();
}
stat_old = stat_new;
});
}
function refreshSlideShow()
{
// you can refresh your slideshow here.
location.reload();
}
</script>
<body>
<style>
#status_fisier, #display_ticker {
position: absolute;
left: 0;
right: 0;
}
#status_fisier {
top: 0;
height: 10%;
background-color: pink;
/* overflow:scroll; */
}
#display_ticker {
bottom: 0;
height: 90%;
background-color: #ddd;
}
</style>
<div id="status_fisier">
</div>
<div id="display_ticker">
<?php include("message.php"); ?>
</div>
</body>
-The content of "check_file_stat.php":
<?php
$locatie_fisier_de_verificat='test_fisier.txt';
/*
The stat() function returns information about a file.
This function returns an array with the following elements:
[0] or [dev] - Device number
[1] or [ino] - Inode number
[2] or [mode] - Inode protection mode
[3] or [nlink] - Number of links
[4] or [uid] - User ID of owner
[5] or [gid] - Group ID of owner
[6] or [rdev] - Inode device type
[7] or [size] - Size in bytes
[8] or [atime] - Last access (as Unix timestamp)
[9] or [mtime] - Last modified (as Unix timestamp)
[10] or [ctime] - Last inode change (as Unix timestamp)
[11] or [blksize] - Blocksize of filesystem IO (if supported)
[12] or [blocks] - Number of blocks allocated
*/
$stat = stat($locatie_fisier_de_verificat);
echo '<p>Verificare stare fisier: "'.$locatie_fisier_de_verificat.'"</p>';
echo '<p>Timpul ultimei modificari (UNIX Timestamp): ' . $stat['mtime'] . "</p>"; /* time of last modification (Unix timestamp) */
echo '<p>Dimensiune in bytes: ' . $stat['size'] . "</p>"; /* size in bytes */
?>
คำแนะนำ และการใช้งาน
สมาชิก กรุณา ล็อกอินเข้าระบบ เพื่อตั้งคำถามใหม่ หรือ ตอบคำถาม สมาชิกใหม่ สมัครสมาชิกได้ที่ สมัครสมาชิก
- ถาม-ตอบ กรุณา ล็อกอินเข้าระบบ
เว็บไซต์ของเราให้บริการเนื้อหาบทความสำหรับนักพัฒนา โดยพึ่งพารายได้เล็กน้อยจากการแสดงโฆษณา
โปรดสนับสนุนเว็บไซต์ของเราด้วยการปิดการใช้งานตัวปิดกั้นโฆษณา (Disable Ads Blocker) ขอบคุณครับ