我有一個網頁,它動態地改變圖片源並使用PHP和JQuery的合成來顯示新圖像。使用PHP每secon更改網頁中的圖片
這是PHP5腳本:
<?php
header("Content-Type: image/jpeg");
$page = $_SERVER['PHP_SELF'];
$sec = "1";
include_once "cookie_checker.php";
function get_file_extension($filename) {
return substr(strrchr($filename, '.'), 1);
}
$path = "./motion";
$latest_ctime = 0;
$latest_filename = '';
$exts = array('jpg');
$d = dir($path);
while (false !== ($entry = $d->read())) {
$filepath = "{$path}/{$entry}";
$extension = strtolower(get_file_extension($entry));
if (is_file($filepath) && filectime($filepath) > $latest_ctime && $extension && in_array($extension,$exts)) {
$latest_ctime = filectime($filepath);
$latest_filename = $entry;
}
}
echo '<img src="/motion/' . $latest_filename . '" />';
?>
這是代碼的JavaScript部分:
var auto_refresh = setInterval(function(){
$('#load_div').load('camera_stream_worker.php');}
, 1000);
HTML其中顯示圖像:
<div id="load_div">
</div>
的腳本作爲它適用於Firefox,但不適用於Internet Explorer。
你能否告訴我如何在Internet Explorer中顯示圖片?
我不明白爲什麼它不起作用。根據定義,PHP是服務器端編程語言,Internet Explorer在客戶端工作。
我想知道爲什麼這個工作在Firefox中,但不是在Internet Explorer中。
謝謝
有些東西在這裏丟失...你在哪裏加載圖像? – Amarnasan
Hello @Amarnasan,我在圖像顯示的代碼中添加了HTML部分。 – depecheSoul