Skip navigation
Currently Being Moderated

Large CFFILE Uploads cause instant 404 error

Oct 1, 2006 7:52 AM

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:
=========================================



 
Replies
  • Currently Being Moderated
    Oct 1, 2006 9:48 AM   in reply to senelson1
    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/av i,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/av i,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>
    >


     
    |
    Mark as:
  • Currently Being Moderated
    Jun 20, 2012 8:40 AM   in reply to senelson1

    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.

     

    http://www.windowsitpro.com/article/windows-gatekeeper-faqs/q-do-i-sti ll-need-to-install-the-urlscan-tool-on-my-microsoft-iis-7-0-web-server -to-filter-malicious-data-from-incoming-http-requests-

     

    http://learn.iis.net/page.aspx/143/use-request-filtering/

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points