File Element
File
Formtools provides a simple file upload option. File field types need to be used in conjunction with a string data type. The formtool expects to store the path to a file media asset in the database field.
Save locations are relative to the system application default file path. The reason for this is to accommodate both open (ie. under the webroot) and secure (ie. under the project root and reached by download.cfm or similar controller) file storage deployments.
Attribute |
Description |
Default Value |
---|---|---|
ftStyle |
Inline style attributes. |
(blank) |
ftDestination |
Location of file; relative to the default file root. |
(blank) |
ftSecure |
Whether or not the file storage should use the secure or open file path for storage |
false |
ftRenderType |
Either "html" or "flash". The flash uploader includes a progress indicator and client side checking of file type and file size. The html rendertype uses a standard html file input. |
flash |
ftFacade |
FLASH ONLY. The path to the file upload handler from the application webroot. |
/webtop/facade/fileupload/upload.cfm |
ftFileTypes |
FLASH ONLY. List of extensions the property that can be accepted in the form ".ext,.abc". |
*.* |
ftFileDescription |
FLASH ONLY. Description of file types that appears in browse dialog. |
File Types |
ftMaxSize |
FLASH ONLY. Maximum file size in bytes. |
-1 (Any) |
ftOnComplete |
FLASH ONLY. ActionScript code to run once an upload is complete. To run JS code on the containing page use getURL('javascript:...') |
(blank) |
File Paths
File formtool refers to application.path.secureFilePath and application.path.defaultFilePath for the absolute file paths to store uploaded files. You can change these values in your project's ./config/_serverSpecificVars.cfm
Often the default file path points directly to ./www/files. Make sure you don't include /files in your ftDestination or you'll end up with something like ./www/files/files
Best Practice
A common best practice is to nominate a destination path that includes the typename and propertyname. For example, for a content type called "dmproposal" and a property of "pdfcoverpage" you might use ftdestination="/dmproposal/pdfcoverpage"
Sample Usage
<cfproperty ftSeq="25" ftfieldset="Cover Page" ftWizardStep="Overview" name="pdfCoverPage" type="string" hint="PDF cover page to merge." required="no" default="" ftlabel="PDF Cover Page" fttype="file" ftDestination="/dmproposal/pdfcoverpage" />
Linking to files
You can link to files using the download.cfm file. Keep in mind that security also applies to files, so if a user isn't allowed to access the object or if the object is in draft, the user will be asked to log in.
#application.url.webroot#/download.cfm?objectid=#objectid#&fieldname=#property#