hackalive Posted October 28, 2011 Share Posted October 28, 2011 Hi guys, I need some PHP/jquery code that constantly checks a folder for when files are added to it, then grabs the file/s and processes them through a php function. Any ideas how I can automate this, I am happy for a browser window to have to be open to do it (that would be the only way I think) but now I just need the web based code to go with it. Any help/suggestions are much appreciated. Cheers in advance. Link to comment https://forums.phpfreaks.com/topic/249996-phpjquery-get-file-as-uploaded/ Share on other sites More sharing options...
The Little Guy Posted October 28, 2011 Share Posted October 28, 2011 I would recommend using a database, but this is a non-database way (NOT TESTED!): function checkFolder(){ $.ajax({ type: "GET", url: "/process/checkfolder.php", success: function(data){ $("#myDiv").append(data); } }); } setInterval("checkFolder()", 10000); // Run checkFolder every 10 seconds session_start(); if(!isset($_SESSION['last_check'])) $_SESSION['last_check'] = 0; $last_check = $_SESSION['last_check']; $_SESSION['last_check'] = time(); $newest_files = array(); foreach(glob("folder/*.*") as $file){ if(filemtime($file) >= $last_check){ $newest_files[] = $file; } } echo "<div>".implode("</div><div>", $newest_files)."</div>"; Link to comment https://forums.phpfreaks.com/topic/249996-phpjquery-get-file-as-uploaded/#findComment-1283091 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.