![]() ![]() ![]() |
||
|
File uploading requires that you create two files:
The following procedures describe how to create these files.
<head><title>Specify File to Upload</title></head> <body> <h2>Specify File to Upload</h2> <!--- the action attribute is the name of the action page ---> <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>
Note: The form will not work until you write an action page for it (see the next procedure).
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 |
<input type="file" name="FiletoUpload" size="45"> |
Allow the user to specify the file to upload. The |
The user can enter a file path or browse the system and select a file to send.
<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>
destination="c:\temp\"
Note: This directory must exist on the server.
The file you specified uploads.
The following table describes the code and its function:
Code |
Description |
---|---|
<cffile action="upload" |
Output the name and location of the uploaded file on the client machine. |
destination="c:\temp\" |
Specify the destination of the file. |
nameConflict="overwrite" |
If the file already exists, overwrite it. |
fileField="Form.FiletoUpload"> |
Specify the name of the file to upload. Do not enclose the variable in number signs. |
You uploaded #cffile.ClientFileName#.#cffile. ClientFileExt# successfully to #cffile.ServerDirectory#. |
Inform the user of the file that was uploaded and its destination. For information on |
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 and Handling Errors.
This section describes the following topics:
|
||
![]() ![]() ![]() |