0

Hello,

I have folder on remote FTP server that is updated with more than XML file with different names in asynchronous (not scheduled time), I want to make a PHP application that fetch any new XML file arrives at the FTP automatically, so how can I make the PHP application fetching any XML file based on the arrival of XML file?

Thanks a lot.

2
Contributors
10
Replies
11
Views
6 Years
Discussion Span
Last Post by pritaeas
0

Start with the PHP FTP manual.

Thanks already I know it, but I need to know how to synchronize between the FTP folder and PHP application, I need the PHP to fetch the XML file only when it arrives, how to do that mechanism?

Thanks.

0

You cannot get a message from the ftp server, but you can poll to see if there are new files (by fetching the rawlist). The only problem can be that a file is still being written the moment you access it.

0

OK, but you mean the PHP function (rawlist) will be executed periodically? What script shall I write to make the PHP application listens to the FTP server to see if there is new file added?

Please advise and thanks..

0

You'd need a PHP file that connects to the FTP server, retrieves the current folder list, and compare that with what you don't have. You can then schedule this script with cron, to run it at a given interval.

0

You'd need a PHP file that connects to the FTP server, retrieves the current folder list, and compare that with what you don't have. You can then schedule this script with cron, to run it at a given interval.

Thanks, so the idea is to make time scheduling, like to make the PHP application to check the folder every 5 mints?

One more question, do you have an example of the scheduling with cron in linux? I am not familiar with that command.

Thanks.

0

You can't. What you can do is compare the file sizes too. If they have changed since the last time then wait, otherwise retrieve the new file. This is still not fail proof since a file could be uploaded partially, aborted and then continued.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.