views:

46

answers:

3

hi For various dull reasons, I'd like to assay a script that looks at the files in a directory, copies the filename of the latest and inserts it into a mysql table. It shld also check if the insert has been done already.

I am a web tinkerer (i work in construction) so my question may seem a bit ingenue but what functions do I need to get the filenames of files in a particular directory ? I can see how to check if the insert's been done already plus the db insert bits. I just wanna learn how to get hold of the latest filename.

Afterthought: is there a way to run the script automatically or on completion of a successful ftp upload to the directory in question ?

Tom

+2  A: 

I would recommend the SPL DirectoryIterator instead of glob().

Macmade
Yea, I would to. Good call! +1
Brad F Jacobs
A: 

To answer your second question:

Afterthought: is there a way to run the script automatically or on

completion of a successful ftp upload to the directory in question ?

This depends on the type of server you're running on, since you're programming in PHP, I'll assume it's a Unix or Linux based machine, in which case you'll want to read up on CRONTAB, which is the normal way of running scripts at a specific time.

It would be difficult on the server end to know when a client has finished uploading via FTP, as you likely really don't know how many files they might upload.

direct00
A: 

thank you all: helpful comments all round tom

Ptarmigan