philaj Posted June 4, 2019 Share Posted June 4, 2019 Hi All - hope someone has done this before. I need to create a PHP script that detects the presence of a new file appearing into a folder, and process it. This HAS to be supported by Windows IIS (Have looked at FAM for Linux but can't use it). I could do a loop with some sleep that checks the directory every x seconds - but this has been discounted by the client as either a) too resource hungry or b) not quick enough if there is a delay. Add ons, extensions or even external 3rd party tools would all be acceptable. Any ideas? Phil Quote Link to comment Share on other sites More sharing options...
ginerjm Posted June 4, 2019 Share Posted June 4, 2019 How do these files actually "appear" in your system? Can you not be alerted to a new upload before or as it happens? Quote Link to comment Share on other sites More sharing options...
requinix Posted June 4, 2019 Share Posted June 4, 2019 Hypothetically you could use the COM/DOTNET extension and use .NET's FileSystemWatcher. Quote Link to comment Share on other sites More sharing options...
philaj Posted June 6, 2019 Author Share Posted June 6, 2019 ginerjm - The files are ftp'd into a location - and my script needs to process them. Thanks requinix I'll check that out Quote Link to comment Share on other sites More sharing options...
Phi11W Posted June 6, 2019 Share Posted June 6, 2019 On 6/4/2019 at 10:50 AM, philaj said: I need to create a PHP script that detects the presence of a new file appearing into a folder, and process it. This HAS to be supported by Windows IIS IIS implements a Request-Response model. It's not suited to long-running or cyclical processes. However, PHP code doesn't only run inside IIS. You can run it as a standalone program by "feeding" the PHP script file into the PHP executable. php.exe -f myscript.php That means that you can create a PHP script that does whatever you want it to, and schedule it to run whenever you need it to run using, say, Windows Task Scheduler. Quote Link to comment Share on other sites More sharing options...
maxxd Posted June 6, 2019 Share Posted June 6, 2019 It's a kludge, but you could always keep a list of files in a database or flatfile and schedule a CRON to run a script that scans the directory for file names, then compare that to the saved list. You'd know if something had been added or removed, though it wouldn't be instant. Quote Link to comment Share on other sites More sharing options...
ginerjm Posted June 6, 2019 Share Posted June 6, 2019 This FTP process. Could you possibly have an influence on those doing those transfers to use a script that you provide that would not only send you the file but send a message to a script that monitors an email address of yours and follows up by doing your processing? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.