FTP incoming monitor (on upload)

2019-08-01 10:22发布

问题:

We have a few 100 users logging in via FTP and uploading files. Our online system (PHP) should display items that have just been uploaded. I don't want to keep checking all the different FTP folders to check for new files.

What is the best way to check for new files with PHP without slowing down the server? All the users have files in folders for example, /uploads/user1, /uploads/user2, etc. The approach I have in mind is the following:

  • Constantly check uploads folder to check if the folder modification date has changed (if the date has changed from last time, a file has come in). What PHP function can I use to check upload directory last modified date/time?
  • If above date modified has changed, Use scandir() to go through each directory to pickup directory that has changed to identify files.

回答1:

Enable logging in your FTP server, and parse the log, usually /var/log/xferlog . FTP servers usually use a format like this.



标签: php ftp