ColdFusion - How to upload a file into web server

cffile - upload file

cffileupload.cfm



<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>ColdFusion cffile tag example: how to upload file</title>
</head>

<body>
<h2 style="color:DodgerBlue">ColdFusion cffile tag example: Upload</h2>

<cfset UploadFolder="C:\Upload">
<cfif IsDefined("Form.UploadFile") AND Form.UploadFile NEQ "">
 <cffile 
     action="upload" 
        filefield="UploadFile" 
        destination="#UploadFolder#" 
        nameconflict="overwrite"
        >
 File uploaded successfully!
    <br />
    Uploaded file: <cfoutput>#cffile.ClientFile#</cfoutput>
<cfelse>
 Select a file first!        
</cfif>

<form name="UploadForm" method="post" enctype="multipart/form-data" action="">
 <input type="file" name="UploadFile">
    <input type="submit"  name="submit" value="Upload"/>
</form>

</body>
</html>

















More ColdFusion examples