ArtsAutosBooksBusinessEducationEntertainmentFamilyFashionFoodGamesGenderHealthHolidaysHomeHubPagesPersonal FinancePetsPoliticsReligionSportsTechnologyTravel

Coldfusion: allowing max file size when uploading

Updated on October 14, 2012


As a web developer, you will build routines or functions to allow the user to upload an image, xls file, pdf file, etc. It is always a good rule, to limit the max file size that the user is uploading. This will eliminate other issues that may arise due to a large file being uploaded. One that comes to mind, is a timeout issue, which than leads to a frustrated user. Try to build your web applications with the user in mind. Limit any possible pitfalls that could occur on the user side.

Coldfusion Code:

Below is the sample Coldfusion code when the file is uploaded.

// if the form is submitted, do the following

<CFIF isdefined ("uploadfile")>


         <cflocation addtoken="no"
                         url="index.cfm?Note=File too Large! (#VAL(CGI.CONTENT_LENGTH/1000)# KB)">



       <cflocation addtoken="no"
                       url="index.cfm?Note=File Uploaded (#VAL(CGI.CONTENT_LENGTH/1000)# KB)">



HTML Form Code:

below is the sample HTML for the form that will actually upload the file.

<cfparam name="URL.Note" default="">
   <strong><font color="RED">#URL.NOTE#</font></strong>

<cfform action="index.cfm?uploadfile=yes" method="post" enctype="multipart/form-data">
What File:
<cfINPUT NAME="WhatFile" TYPE="File" SIZE="60" required="yes" message="Please select file">
<input type="Submit" value="Upload File">


Submit a Comment

No comments yet.