MACROMEDIA COLDFUSION MX 61-DEVELOPING COLDFUSION MX Develop Manual page 821

Developing coldfusion mx applications
Table of Contents

Advertisement

Note: The form will not work until you write an action page for it (see the next procedure).
Reviewing the code
The following table describes the code and its function:
Code
<form action="uploadfileaction.cfm"
enctype="multipart/form-data"
method="post">
<input type="file"
name="FiletoUpload"
size="45">
The user can enter a file path or browse the system and select a file to send.
Create a ColdFusion page with the following content:
1
<html>
<head> <title>Upload File</title> </head>
<body>
<h2>Upload File</h2>
<cffile action="upload"
destination="c:\temp\"
nameConflict="overwrite"
fileField="Form.FiletoUpload">
<cfoutput>
You uploaded #cffile.ClientFileName#.#cffile.ClientFileExt#
successfully to #cffile.ServerDirectory#.
</cfoutput>
</body>
</html>
Change the following line to point to an appropriate location on your server:
2
destination="c:\temp\"
Note: This directory must exist on the server.
Save the file as uploadfileaction.cfm in the myapps directory under your web_root.
3
View uploadfileform.cfm in the browser, enter a file to upload, and submit the form.
4
The file you specified uploads.
Description
Create a form that contains file selection fields for
upload by the user. The
the ColdFusion template that will process the submitted
form. The
attribute value tells the server that the
enctype
form submission contains an uploaded file. The
attribute is set to
to submit a ColdFusion form.
post
Allow the user to specify the file to upload. The
type instructs the browser to prepare to read and
transmit a file from the user's system to your server. It
automatically includes a Browse button to let the user
look for the file instead of manually entering the entire
path and filename.
attribute value specifies
action
Using cffile
method
file
821

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion mx

Table of Contents