tags:

views:

27

answers:

4

I need to determind when a file has been uploaded via an ftp account so i can parse the data and insert into a db.

I could do this 2 different ways, either set up a schedule or watch the directory for any change. Either option would be fine.

I'm new to the apache /php space so any keywords that i can search upon would be handy.

Thanks.

A: 

You could do this using a cron job and any language you like, really.

Cron is a time-based job scheduler in Unix-like computer operating systems (Wikipedia)

Just have a directory which gets filled with files which need to be processed, then process them and remove them on a regular basis. You could have this job run every five minutes or whenever you like, depending on how time sensitive these files are.

Jamie Wong
A: 

You would have to set up a server-side cron job to trigger a PHP file that makes the check frequently. On Linux the tool is called cron, on Windows at. If you're on shared hosting, you will need to check whether it's supported: It will most likely turn up in your control panel software if it is.

Watching the directory would require hooking into the FTP server software, or installing a file system watcher. Both things are possible but very much depend on your server environment (and require root access to the server).

Pekka
A: 

I would suggest to check if the file is there, then before processing, move/rename it (filename_[somethingunique]) so that only the current session will access the file.

Otherwise you may end up 2 scripts inserting same data.

Imre L
A: 

Ideally you will need a cron job. Here is a good description of cron and short tutorial.

Thariama