Dealing with Files

The CFFILE tag handles all file manipulation that takes place on the local ColdFusion server. The CFFILE tag has three purposes. First, it makes it possible to upload files to the ColdFusion server via an HTML form. This means you can design forms that allow users to upload files from their machines directly to your ColdFusion server. This lets you create things such as web-based email clients, document management systems, and other applications that require users to upload files to your server. The second purpose of the CFFILE tag is to allow you to manipulate files located on your ColdFusion server. The CFFILE tag allows you to rename, move, copy, and delete files on the ColdFusion server. The final purpose of the CFFILE tag is to allow you to read, write, and append both text and binary files.

Uploading Files

Enabling file uploads is one of the more popular uses for the CFFILE tag. To do this, you first have to include a file input type in an HTML form. This allows a user to select a file from their system and post it along with the other form fields. When the form is submitted, the file is posted to the server/template specified in the ACTION attribute of the FORM tag. The receiving template then uses a CFFILE tag to process the uploaded file.

You should exercise extreme caution when implementing the CFFILE tag’s Upload action within your ColdFusion applications. Because the tag allows users to upload files directly to your ColdFusion server, you need ...

Get Programming ColdFusion now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.