Using cffile Parameters
The previous lesson showed the parameters that are available to developers when the
cffile tag is used to upload a file to the server. These parameters are available in the 'file' scope and can be used in a number of ways.
One common technique is to insert some/all of these parameters into a database. If you do this, later on you can use the database to lookup the details of any file that has been uploaded to the server. This can be useful if you want to dynamically render details about the file to the user.
For example, you could use the
serverFileExt parameter to display the appropriate icon (Word icon, PDF icon etc). You could also use the
fileSize parameter to display the file size to the user. This is good usability practice — especially if the file is large. You could even create an image library for users to browse images and view their details if you wish.
In the following example, I have modified the code from the file upload page so that we are now inserting details about the file into a database. This, of course, assumes you have a database configured with the appropriate datasource/tables/columns etc