MACROMEDIA COLDFUSION 4.5-DEVELOPING WEB Develop Manual page 247

Developing web applications with coldfusion
Table of Contents

Advertisement

Chapter 14: Managing Files on the Server
Code Review
Code
<FORM ACTION="uploadfileaction.cfm"
<INPUT TYPE="file"
HTML forms can be designed in most browsers to give users the ability to upload files.
Setting the HTML INPUT tag type to "file" instructs the browser to prepare to read and
transmit a file from the user's system to your server. Setting the ENCTYPE FORM
attribute to "multipart/form-data" tells the server that the form submission contains
an uploaded file.
The user can enter a file path or browse the system and pick a file to send.
To create an action page to upload the file:
1.
Create a new file in Studio.
2.
Modify the file so that it appears as follows:
<HTML>
<HEAD>
</HEAD>
<body>
<H2>Upload File</H2>
<CFFILE ACTION="UPLOAD"
<CFOUTPUT>
You uploaded the file #File.ClientFileName#.#File.ClientFileExt#
successfully to
#File.ServerDirectory#\#File.ServerFileName#.#File.ServerFileExt#.
</CFOUTPUT>
</BODY>
</HTML>
ENCTYPE="multipart/form-data"
METHOD="post">
NAME="FiletoUpload"
SIZE="45">
<TITLE>Upload File</TITLE>
DESTINATION="c:\inetpub\wwwroot\HR\"
NAMECONFLICT="Overwrite"
FILEFIELD="FiletoUpload">
Description
Create a form that contains file
selection fields for upload by the
user.
Allow the user to input a field.
(The File input type
automatically includes a Browse
button to allow the user to look
for the file instead of entering
the entire path and file name.)
221

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 4.5

Table of Contents