Upload Files with Coldfusion
1. Create a new page in DW and save it as "uploadfile.cfm".
2. Create a normal form with a file field.
<form action="uploadfile.cfm" method="POST" name="frmupload" enctype="multipart/form-data">
<input type="file" name="file_path">
<input type="submit" name="submit_upload" value="upload">
</form>
3. We will send the form to the same page and perform the upload here too. Add the following code above the <form> tag we just created:
<cfif isdefined("form.submit_upload")>
<cffile action="UPLOAD" filefield="file_path" destination="C:\Documents and Settings\Administrator\Desktop" nameconflict="MAKEUNIQUE">
File Uploaded!
</cfif>
FULL CODE:
<html><head><title>Upload File with Coldfusion</title></head><body>
<cfif isdefined("form.submit_upload")>
<cffile action="UPLOAD" filefield="file_path" destination="C:\inetpub\wwwroot" nameconflict="MAKEUNIQUE">
File Uploaded!
</cfif>
<form action="uploadfile.cfm" method="POST" name="frmupload" enctype="multipart/form-data">
<input type="file" name="file_path">
<input type="submit" name="submit_upload" value="upload">
</form>
</body></html>
Recent comments
6 years 19 weeks ago
8 years 41 weeks ago
10 years 30 weeks ago
11 years 52 weeks ago
12 years 25 weeks ago
12 years 25 weeks ago
12 years 29 weeks ago
12 years 30 weeks ago
12 years 30 weeks ago
12 years 32 weeks ago