Tutorial :php latest upload



Question:

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


Solution:1

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


Solution:2

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.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »