Skip navigation.
Home

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>