myelecproject
04-04-2012, 02:20 AM
hello im working on my senior design project for my electrical engineering class. and part of the project is to upload an image via php (which ive written and it works great) but when the image is loaded into the same directory as the html file (which is supposed to display the image everytime a new image is uploaded) the image stays the same it doesnt show the new image. but i kno the new image has been uploaded because i can see it my web server. this is the code
<html>
<head>
<title>Human Cam</title>
<script type = "text/javascript">
function refresh() {
var refreshTime = 5*1000; //5000ms
var thisImage = "Lighthouse.jpg"; //the image location
var today = new Date(); //the current time
//add the time to the end of the image string
//to make a unique url:
document.images["pic"].src=thisImage+"?"+today;
//reload if the images are loaded:
if (document.images) {
window.onload=refresh;
}
//IF the time is up reload the image
t=setTimeout('refresh()', refreshTime);
}
</script>
</head>
<body onload="refresh()">
<center>
<h2>human cam</h2>
<img src="Lighthouse.jpg" id="pic">
</center>
</body>
</html>
<html>
<head>
<title>Human Cam</title>
<script type = "text/javascript">
function refresh() {
var refreshTime = 5*1000; //5000ms
var thisImage = "Lighthouse.jpg"; //the image location
var today = new Date(); //the current time
//add the time to the end of the image string
//to make a unique url:
document.images["pic"].src=thisImage+"?"+today;
//reload if the images are loaded:
if (document.images) {
window.onload=refresh;
}
//IF the time is up reload the image
t=setTimeout('refresh()', refreshTime);
}
</script>
</head>
<body onload="refresh()">
<center>
<h2>human cam</h2>
<img src="Lighthouse.jpg" id="pic">
</center>
</body>
</html>