How about adding a <cftry> and check for the file size?
Something like this:
<!--- upload file --->
<cftry>
<cffile
action="upload"
accept="audio/mpeg,video/x-ms-wmv,video/mpeg,video/quicktime,video/avi,audio/midi"
filefield="UploadedFile"
destination="#LibraryDirectory#\"
nameconflict="overwrite">
<!--- Check for file size --->
<cfif CFFILE.FileSize GT 2097152>
<!--- Throw an error --->
<cfthrow
type="SizeError"
message="The file is too large. It cannot be more than
2MB.">
</cfif>
<!--- Catch the error --->
<cfcatch type="SizeError">
<!--- Show error message --->
<cfabort showerror="#CFCATCH.Message#">
</cfcatch>
</cftry>
--
Ken Ford
Adobe Community Expert
"senelson1" <webforumsuser@macromedia.com> wrote in
message
news:efokmt$300$1@forums.macromedia.com...
>I have the strangest issue. CFFILE uploads files up to
about 2mb just fine
>but
> larger files cause a instantainious 404 error. The
address bar still shows
> the
> 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
> memory
> 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
> insufficiant
> memory error insteaqd of the 404 page.
>
> Any suggestions?
>
> Scott
>
> 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," ","_")#">
> <CFTRY>
> <cfif (#UploadedFile# EQ "") OR (#NewServerFile# EQ
"")>
> <br><br>
> <p align="center"
class="Black_Headline">ERROR</p>
> <p align="center" class="bodybold">You need to
specify a new name (can
> be
> 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
> and
> try again.</p>
> <cfelse> <!--- #Form.UploadedFile# IS ''
--->
>
> <!--- parameters --->
> <CFSET LibraryDirectory = "#media_lib#">
> <!--- upload file --->
> <CFFILE ACTION="UPLOAD"
>
>
ACCEPT="audio/mpeg,video/x-ms-wmv,video/mpeg,video/quicktime,video/avi,audio/mid
> i"
> FILEFIELD="UploadedFile"
> DESTINATION="#LibraryDirectory#\"
> NAMECONFLICT="OVERWRITE">
>
> <!--- rename file --->
> <CFSET SourceName = LibraryDirectory & '\' &
File.ServerFile>
> <CFSET DestinationName = LibraryDirectory & '\'
& tmpFile>
> <CFIF "#SourceName#" NEQ "#DestinationName#">
> <CFFILE
> action="RENAME"
> source="#SourceName#"
> destination="#DestinationName#"
> >
> </CFIF>
>
> <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#">
> </CFCATCH>
> </CFTRY>
>