Coldfusion: allowing max file size when uploading


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">

More by this Author

  • Gun Laws in Georgia

    Firearms can be a very dangerous tool in the hands of the wrong person. Every state has their own gun laws and regulations. For the state of Georgia, the laws are pretty straight forward and easy to abide by. Before you...

  • How to Get Rid of Mice In and Around The House?

    Until this year, the only time that I've had mice or rats in the house were when my daughter had pet mice and rats, and one of those times we did have one loose in the house. (Science fair project got loose.) Anyway,...

  • How to Build Wooden Roof Trusses

    You may refer to a truss as the rafter, but it's basically the skeleton of the roof, carrying the weight of the frame and supporting the walls of the building. Trusses are very important to preventing the walls from...

Click to Rate This Article