I want to create an FTP drop on a server, where files can be uploaded to certain directories via FTP, and then be processed by a PHP script (run as a cron job or daemon).
It's no problem to FTP the files, or to read them from the directory. But how would the PHP script know if the file upload is complete or still in progress?
I could repeatedly check if the filesize has changed over a period of time, and process the files if it does not change for 1 minute. But this does not seem like an elegant solution and I imagine it could go wrong at times, such as if the upload is paused or fails for some reason.
Another way could be to upload a blank text file after each file, with a variation on the name (such as competed.filename). Then the script could check for the presence of these files and process the corresponding files. But this is also not an elegant solution and possibly prone to going wrong somewhere.
Is there a good way to check with PHP if an FTP file upload has completed successfully?