Question : Check folder for new file

Looking for a client-side script (ie javascript / xml / ajax) that would be on a webpage and check a folder (on the same domain as the webpage) for any new files. If a new file is found, it will then do something (like refresh the page).

Answer : Check folder for new file

@gibu_george
Why not?

PHP can scan through folders on the webserver, see code snippet below. The trick is to have it compared to a previous scan. You could store each scan in a session variable, and compare it server-side, or after each ajax-call, compare the two arrays client-side by JavaScript.
1:
2:
3:
4:
5:
6:
7:
8:
9:
	function getFilesInDirectory($directory) {
		$results = array();
		$handler = opendir($directory);
		while ($file = readdir($handler)) {
			$results[] = $file;
		}
		closedir($handler);
		return $results;
	}
Open in New Window Select All
Random Solutions  
 
programming4us programming4us