Hello, I'm trying to use a file directory on my ftp server as a database. Here's the application: I have a camera taking pictures every so often and I would like to output the last image taken on a site I've created. I figured using datelastmodified would be the simplest solution, but I can't seem to figure out how to pull the last image without importing all that information into a access or sql database (I'm a novice if you can't tell ). Has anyone done this?
here is a quick bit of code you can play with.. <cfdirectory action="LIST" sort="datelastmodified desc" directory="C:\your full image directory path" name="dir"> <cfoutput> <img src="directory path(relative or absolute)\#dir.name[1]#"> </cfoutput> the cfdirectory tag brings back a list of files, the sort="datelastmodified desc" ensures they are sorted from most recent to least recently modified.. dir.name[1] returns the filename of the most recently modified file in the directory. if you want a look at all the other attributes you have access to do a <cfdump var="#dir#">
Jamie18 has got the right idea While cfdirectory is probably the simplest solution, its not the best solution over time. The more files you have, the larger and slower the query. Ultimately a database is the better solution since it allows you retrieve only what you need (ie one record).