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 to ...
Get Programming ColdFusion MX, 2nd Edition 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.