cffile - upload only image file
cffileUploadImge.cfm
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>cffile tag: how to upload only image file in coldfusion</title>
</head>
<body>
<h2 style="color:DodgerBlue; font-style:italic">cffile example: Upload Image</h2>
<hr width="350" align="left" color="PaleVioletRed" />
<cfset UploadFolder="C:\UploadImage">
<h3 style="color:DeepPink; font-style:italic;">
<cfoutput>
<cfif DirectoryExists(UploadFolder)>
<cfif IsDefined("Form.UploadFile") AND Form.UploadFile NEQ "">
<cftry>
<cffile
action="upload"
filefield="UploadFile"
destination="#UploadFolder#"
nameconflict="overwrite"
accept="image/*"
>
File uploaded successfully!
<br />
Uploaded file: #cffile.ClientFile#
<cfcatch type="any">
Error: #cfcatch.Message#
</cfcatch>
</cftry>
<cfelse>
Select a file first!
</cfif>
<cfelse>
Upload Directory not exists
</cfif>
</cfoutput>
</h3>
<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>