rullbandspelare Posted November 21, 2007 Share Posted November 21, 2007 I have a directory that contains images wich are displayed with this code: (All it does, is going through all the images in the directory and displays them). <?php function file_type($file){ $path_chunks = explode("/", $file); $thefile = $path_chunks[count($path_chunks) - 1]; $dotpos = strrpos($thefile, "."); return strtolower(substr($thefile, $dotpos + 1)); $bild = $_POST["bild"]; } $file_count = 0; $path = "../images/"; $file_types = array( 'jpg', 'png', 'gif'); $p = opendir($path); while (false !== ($filename = readdir($p))) { $files[] = $filename; } sort($files); foreach ($files as $file) { $extension = file_type($file); if($file != '.' && $file != '..' && array_search($extension, $file_types) !== false){ $file_count++; echo '<a href="../index.php"target="_top"><img src="'.$path.$file.'" width="110" height="90"></a><br>'.$file.''.'<br> '; } } if($file_count == 0){ echo "<b>EMPTY</b>"; } ?> It is important that it is automaticaly refreshed when the directory content changes. Now I have put a <meta http-equiv="refresh" content="20"> there. But it is important that it does not refresh when no new images are arriving/leaving the directory. I have some control on how the add/delete is carried out. So i could add a "flagfile" to indicate if something has been removed or added. and base the refresh on that ...or? HELP! Can this be done with the help of AJAX?Any input is appreciated! /tomas Link to comment https://forums.phpfreaks.com/topic/78307-refresh-page-when-a-file-is-uploaded/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.