coldfusioncffile

ColdFusion cffile action="read" how to get metadata?


If you use cffile action = "upload" you get a load of meta data (e.g., the filesize, fileextension etc.).

How do you get the same data for a file that already exists on your server?

I would expect cffile action="read" to give this but it seems it only gives the content of the file, not the metadata relating to it.

I've googled for this and unless I'm missing something it seems the only way to get the meta data is to upload the file.


Solution

  • You need GetFileInfo function. You need to pass path of file to this function. Please check the documentation.

    Example:

    <cfset fileinfo = GetFileInfo(temp.pathtoyourfile)>
    <cfdump var='#fileinfo#' label="fileinfo">