How about adding a <cftry> and check for the file size?
Something like this:
<!--- upload file --->
<!--- Check for file size --->
<cfif CFFILE.FileSize GT 2097152>
<!--- Throw an error --->
message="The file is too large. It cannot be more than 2MB.">
<!--- Catch the error --->
<!--- Show error message --->
Adobe Community Expert
"senelson1" <firstname.lastname@example.org> wrote in message
>I have the strangest issue. CFFILE uploads files up to about 2mb just fine
> larger files cause a instantainious 404 error. The address bar still shows
> URL of the form page, not the processing page. I have CFTRY implimented
> and it
> works - just not if I try to upload a huge file.
> If I understand correctly, an uploaded file from a form is placed in
> first, before reaching the CFFILE command. If this is true, I see no way
> to pre
> test the size of a file before upload because it would still be placed in
> memory (and error).
> This leaves me with trying to find an elegant way to display the
> memory error insteaqd of the 404 page.
> Any suggestions?
> Processing script attached:
> <CFPARAM NAME="media_lib" DEFAULT="#FileRoot#\media">
> <!--- new name for the uploaded file? --->
> <CFSET NewServerFile = "#Form.ServerFile#">
> <cfset tmpFile = "#Trim(NewServerFile)#">
> <cfset tmpFile = "#LCase(tmpFile)#">
> <cfset tmpFile = "#ReplaceList(tmpFile," ","_")#">
> <cfif (#UploadedFile# EQ "") OR (#NewServerFile# EQ "")>
> <p align="center" class="Black_Headline">ERROR</p>
> <p align="center" class="bodybold">You need to specify a new name (can
> the same but the field can not be blank) and a file to upload.</p>
> <p align="center" class="bodybold">Please use your browser's back button
> try again.</p>
> <cfelse> <!--- #Form.UploadedFile# IS '' --->
> <!--- parameters --->
> <CFSET LibraryDirectory = "#media_lib#">
> <!--- upload file --->
> <CFFILE ACTION="UPLOAD"
> <!--- rename file --->
> <CFSET SourceName = LibraryDirectory & '\' & File.ServerFile>
> <CFSET DestinationName = LibraryDirectory & '\' & tmpFile>
> <CFIF "#SourceName#" NEQ "#DestinationName#">
> <cflocation url="p_admin_menu.cfm?mode=media_lib" addtoken="No">
> </cfif> <!--- #Form.UploadedFile# IS '' --->
> <CFCATCH TYPE="any">
> <cflocation url="p_mime_error.cfm?sfile=#UploadedFile#&tfile=#tmpFile#">
After more testing I'm not sure this is even a CF issue. If I post to a blank template I still get the 404 error on large files. I can post to a non-processing page like the index.cfm and the URL changes to index.cfm but there's still the 404 error. If I refresh the index.cfm with the 404 error, the index page comes up fine. I've even tried posting to an existing HTML file and the same thing happens, so I'm baffeled and don't know where to look next. Could it be a Windows/IIS issue?
I found the answer!
IIS Lockdown and URLScan upload size limit
A server running the Microsoft tools IIS Lockdown and URLScan rejects large uploads with a 404 Not Found error.
The new version 2.5 update of URLScan enforces a 30 MB limit on HTTP request size by default.
URLscan is usually located in the directory C:\Windows\system32\inetsrv\urlscan. Navigate to this directory and edit the urlscan.ini file. By default, this file has the entry:
MaxAllowedContentLength = 30000000
which restricts the maximum allowed upload size to 30 MB. Changing this entry to a larger value will allow the server to accept large uploads. You may need to restart IIS for changes to take effect after saving the file.
This has changed with IIS 7. Request filtering is built into the server. All websites default to 30MB upload limit. You can edit the requestLimits in the Configuration Editor for the specific site you want to change. This allows you to keep limits on the remainder of your sites.
Got to system.webServer/security/requestFiltering. Then open and edit maxAllowedContentLength.