I’m writing a PHP process that will run on a Unix machine that will need to monitor a remote SMB server and detect new files that are being uploaded to that box via FTP. It’s unlikely I’ll be able to
It will need to detect:
- New files being created
- File upload completing
- Files being deleted
If it was an NFS share, I’d try using FAM to detect the events, but I can’t see a way of doing anything equivalent?
Doesn’t sound like something I would use in production. But you could try something like this:
the machine that is running a PHP
daemon
RecursiveIteratorIterator with
DirectoryIterator to collect and
maintain a list of all the files and
folders on the shared drive
a while refresh the folder list and
compare it with the current state,
if the file does not exist any more
you know it has been deleted, if
there is a new file put it in the
queue and mark it as “being
uploaded”
check the queued file, it the file
size did not change the file upload
probably completed, if the file size
changed put it in the queue again
and mark it as “being uploaded”