User Guide
Uploading Files 319
Uploading Files
File uploading requires that you create two files:
• An HTML form to enter file upload information
• An action page containing the file upload code
To create an HTML file to specify file upload information:
1 Create a new file in ColdFusion Studio.
2 Modify the file so that it appears as follows:
<html>
<head>
<title>Specify File to Upload</title>
</head>
<body>
<h2>Specify File to Upload</h2>
<form action="uploadfileaction.cfm"
enctype="multipart/form-data"
method="post">
<p>Enter the complete path and filename of the file to upload:
<input type="file"
name="FiletoUpload"
size="45">
</p>
<input type="submit"
value"Upload">
</form>
</body>
</html>
3 Save the file as uploadfileform.cfm in myapps under the Web root directory.
Reviewing the code
The following table describes the code and its function:
Code Description
<form action="uploadfileaction.cfm"
enctype="multipart/form-data"
method="post">
Create a form that contains file selection
fields for upload by the user. The
enctype
attribute value tells the server that the form
submission contains an uploaded file
<input type="file"
name="FiletoUpload"
size="45">
Allow the user to input a field. The file type
instructs the browser to prepare to read and
transmit a file from the user’s system to your
server and automatically includes a Browse
button to allow the user to look for the file
instead of entering the entire path and
filename.