Adobe 38043740 - ColdFusion Standard - Mac Development Manual page 1251

Developing applications
Hide thumbs Also See for 38043740 - ColdFusion Standard - Mac:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Using External Resources
Code
nameConflict="overwrite"
fileField="Form.FiletoUpload">
You uploaded
#cffile.ClientFileName#.#cffile.
ClientFileExt# successfully to
#cffile.ServerDirectory#.
Note: This example performs no error checking and does not incorporate any security measures. Before deploying an
application that performs file uploads, ensure that you incorporate both error handling and security. For more
information, see
"Securing
Applications" on page 339 and
Resolving conflicting filenames
When you save a file to the server, a file with the same name could exist. To resolve this problem, assign one of these
values to the
nameConflict
(default) ColdFusion stops processing the page and returns an error. The file is not saved.
Error
Allows custom behavior based on file properties. The tag does not save the file or return an error.
Skip
Overwrites a file that has the same name as the uploaded file.
Overwrite
Generates a unique filename for the uploaded file. The name is stored in the file object variables
MakeUnique
serverFile and serverFileName. You can use this variable to record the name used when the file was saved. The unique
name might not resemble the attempted name. For more information on file upload status variables, see
the results of a file
upload" on page 1247.
Controlling the type of file uploaded
For some applications, you could want to restrict the type of file that is uploaded, for example, to not accept graphic
files in a document library.
You use the
attribute to restrict the type of file that you allow in an upload. When an
accept
present, the uploaded file MIME content type must match the criteria specified or an error occurs. The
attribute takes a comma-separated list of MIME data names, optionally with wildcards.
The browser determines the file MIME type. Common types, such as image/gif and text/plain, are registered in the
browser.
Note: Current versions of Microsoft Internet Explorer and Netscape support MIME type associations. Other browsers and
earlier versions might ignore these associations.
ColdFusion saves any uploaded file if you omit the
demonstrated in the following examples.
The following
tag saves an image file only if it is in the GIF format:
cffile
<cffile action="Upload"
fileField="Form.FiletoUpload"
destination="c:\uploads\"
nameConflict="Overwrite"
accept="image/gif">
The following
tag saves an image file only if it is in GIF or JPEG format:
cffile
Description
If the file exists, overwrite it.
Specify the name of the file to upload. Do not enclose the variable in number signs.
Inform the user of the file that was uploaded and its destination. For information
on scope variables, see
attribute of the
tag:
cffile
accept
Last updated 1/20/2012
"Evaluating the results of a file
"Handling
Errors" on page 275.
attribute or specify "*/*". You can restrict the file types, as
1246
upload" on page 1247.
"Evaluating
qualifier is
accept
accept

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 9

Table of Contents