Pure ASP Upload - script unable to redirect for larger files

Discussion in 'ASP General' started by ll, Aug 18, 2008.

  1. ll

    ll Guest

    I'm working with 'pure ASP upload' script which is designed to
    redirect to an alert/error message, should
    a file larger than the set limit be attempted to be uploaded. The
    problem is that, while smaller files do upload
    successfully, the script does not catch the larger files and rather
    than a specific error message in Firefox (and IE7), I just get the
    following:
    ------------------------------------
    The connection was reset
    The connection to the server was reset while the page was loading.
    * The site could be temporarily unavailable or too busy. Try
    again in a few
    moments.
    * If you are unable to load any pages, check your computer's
    network
    connection.
    * If your computer or network is protected by a firewall or
    proxy, make sure
    that Firefox is permitted to access the Web.
    ---------------------------------
    here's the script (below) for the database upload. Thanks for any
    help or resources.
    Kind Regards,
    Louis

    ---------------------------------
    '//////////////////////////////////////////////////////////////////////////////////////////////
    'Simple upload to database.
    'Suitable for small files - up to 20% of physical server memory
    'This sample works with any connection - MDB (JetOLEDB, ODBC)
    ' MS SQL (MSDASQL/ODBC) etc.

    'Server.ScriptTimeout = 240
    'Simple upload to database

    Response.Write(Request.QueryString("CourseID"))
    Dim Form: Set Form = New ASPForm %>
    <!--#include virtual="/common/upload/_upload.asp"-->
    <%

    Server.ScriptTimeout = 1000
    Form.SizeLimit = 1024*1024*10'10MB
    MaxFileSize = Form.SizeLimit

    'was the Form successfully received?
    Const fsCompletted = 0

    If Form.State = fsCompletted Then 'Completted

    dim objConnection, RS
    'Open connection to database
    Set objConnection = GetConnection
    Set RS = Server.CreateObject("ADODB.Recordset")


    'Open dynamic recordset, table Upload
    RS.Open "AMS_ContentOverviewLecture", objConnection, 2, 2
    RS.AddNew


    'One-block assigning/AppendChunk is suitable for small files
    '(<20% physical server memory). Plese see documentation to store
    '10th megabytes or more in database.

    'Add file from source field 'SourceFile' to table field 'Data'
    'Store extra form info.
    RS("CourseID") = Form("strCourseID")
    RS("WeekNum") = Form("strWeekNum")
    RS("MainTopicNum") = Form("strMainTopicNum")
    'Add file from source field 'SourceFile' to table field 'Data'
    RS("image_blob") = Form("SourceFile").ByteArray
    'Store technical informations
    RS("ContentType") = Form("SourceFile").ContentType
    RS("filename") = Form("SourceFile").FileName
    strFileName=RS("filename")

    RS("filesize") = Form("SourceFile").Length

    strFolderPath = strFolderPath&strFileName
    RS("FolderPath") = strFolderPath


    RS.Update
    RS.Close

    objConnection.Close


    ElseIf Form.State > 10 then
    Const fsSizeLimit = &HD
    Select case Form.State
    case fsSizeLimit: response.status = "413 Request Entity Too Large"
    response.write "<script type=""text/javascript"">alert (""Source
    form size (" & Form.TotalBytes & "B) exceeds form limit (" &
    Form.SizeLimit & "B) (10MB) \n The file was NOT uploaded"")</script>"
    Response.End()
    'Server.Transfer(Request.ServerVariables("PATH_INFO") & "?" &
    Request.ServerVariables("Query_String"))
    case else response.write "<br><Font Color=red>Some form error.</
    Font><br>"
    end Select
    End If
    ll, Aug 18, 2008
    #1
    1. Advertising

  2. "ll" <> wrote in message
    news:...
    > I'm working with 'pure ASP upload' script which is designed to
    > redirect to an alert/error message, should
    > a file larger than the set limit be attempted to be uploaded. The
    > problem is that, while smaller files do upload
    > successfully, the script does not catch the larger files and rather
    > than a specific error message in Firefox (and IE7), I just get the
    > following:
    > ------------------------------------
    > The connection was reset
    > The connection to the server was reset while the page was loading.
    > * The site could be temporarily unavailable or too busy. Try
    > again in a few
    > moments.
    > * If you are unable to load any pages, check your computer's
    > network
    > connection.
    > * If your computer or network is protected by a firewall or
    > proxy, make sure
    > that Firefox is permitted to access the Web.
    > ---------------------------------
    > here's the script (below) for the database upload. Thanks for any
    > help or resources.
    > Kind Regards,
    > Louis
    >
    > ---------------------------------
    >

    '///////////////////////////////////////////////////////////////////////////
    ///////////////////
    > 'Simple upload to database.
    > 'Suitable for small files - up to 20% of physical server memory
    > 'This sample works with any connection - MDB (JetOLEDB, ODBC)
    > ' MS SQL (MSDASQL/ODBC) etc.
    >
    > 'Server.ScriptTimeout = 240
    > 'Simple upload to database
    >
    > Response.Write(Request.QueryString("CourseID"))
    > Dim Form: Set Form = New ASPForm %>
    > <!--#include virtual="/common/upload/_upload.asp"-->
    > <%
    >
    > Server.ScriptTimeout = 1000
    > Form.SizeLimit = 1024*1024*10'10MB
    > MaxFileSize = Form.SizeLimit
    >
    > 'was the Form successfully received?
    > Const fsCompletted = 0
    >
    > If Form.State = fsCompletted Then 'Completted
    >
    > dim objConnection, RS
    > 'Open connection to database
    > Set objConnection = GetConnection
    > Set RS = Server.CreateObject("ADODB.Recordset")
    >
    >
    > 'Open dynamic recordset, table Upload
    > RS.Open "AMS_ContentOverviewLecture", objConnection, 2, 2
    > RS.AddNew
    >
    >
    > 'One-block assigning/AppendChunk is suitable for small files
    > '(<20% physical server memory). Plese see documentation to store
    > '10th megabytes or more in database.
    >
    > 'Add file from source field 'SourceFile' to table field 'Data'
    > 'Store extra form info.
    > RS("CourseID") = Form("strCourseID")
    > RS("WeekNum") = Form("strWeekNum")
    > RS("MainTopicNum") = Form("strMainTopicNum")
    > 'Add file from source field 'SourceFile' to table field 'Data'
    > RS("image_blob") = Form("SourceFile").ByteArray
    > 'Store technical informations
    > RS("ContentType") = Form("SourceFile").ContentType
    > RS("filename") = Form("SourceFile").FileName
    > strFileName=RS("filename")
    >
    > RS("filesize") = Form("SourceFile").Length
    >
    > strFolderPath = strFolderPath&strFileName
    > RS("FolderPath") = strFolderPath
    >
    >
    > RS.Update
    > RS.Close
    >
    > objConnection.Close
    >
    >
    > ElseIf Form.State > 10 then
    > Const fsSizeLimit = &HD
    > Select case Form.State
    > case fsSizeLimit: response.status = "413 Request Entity Too Large"
    > response.write "<script type=""text/javascript"">alert (""Source
    > form size (" & Form.TotalBytes & "B) exceeds form limit (" &
    > Form.SizeLimit & "B) (10MB) \n The file was NOT uploaded"")</script>"
    > Response.End()
    > 'Server.Transfer(Request.ServerVariables("PATH_INFO") & "?" &
    > Request.ServerVariables("Query_String"))
    > case else response.write "<br><Font Color=red>Some form error.</
    > Font><br>"
    > end Select
    > End If


    By default IIS6 has maximum entity body limit set to 200K. Any POST which
    carries a Content-Length greater than 200K will be rejected immediately by
    IIS it'll drop the connection in order to prevent inbound bandwidth being
    consumed by the upload.


    --
    Anthony Jones - MVP ASP/ASP.NET
    Anthony Jones, Aug 19, 2008
    #2
    1. Advertising

  3. ll

    Toni Guest

    "Anthony Jones" wrote...
    >

    :> By default IIS6 has maximum entity body limit set to 200K. Any POST which
    > carries a Content-Length greater than 200K will be rejected immediately by
    > IIS it'll drop the connection in order to prevent inbound bandwidth being
    > consumed by the upload.
    >
    >
    > --
    > Anthony Jones - MVP ASP/ASP.NET


    Anthony, can you tell me if there is a setting to increase that 200K upload limit?

    And does this 200K limit only apply to ASP scripts, or is it applicable to CGI scripts
    running on IIS6 as well?

    Thanks!

    Toni
    Toni, Aug 19, 2008
    #3
  4. "Toni" <> wrote in message
    news:...
    > "Anthony Jones" wrote...
    > >

    > :> By default IIS6 has maximum entity body limit set to 200K. Any POST

    which
    > > carries a Content-Length greater than 200K will be rejected immediately

    by
    > > IIS it'll drop the connection in order to prevent inbound bandwidth

    being
    > > consumed by the upload.
    > >
    > >
    > > --
    > > Anthony Jones - MVP ASP/ASP.NET

    >
    > Anthony, can you tell me if there is a setting to increase that 200K

    upload limit?
    >
    > And does this 200K limit only apply to ASP scripts, or is it applicable to

    CGI scripts
    > running on IIS6 as well?


    The metabase property AspMaxRequestEntityAllowed defaults to 200K so for
    POST to ASP you need to increase this limit.

    The overall IIS limit is controlled by MaxRequestEntityAllowed which
    defaults to 4GB therefore should not be a problem.


    --
    Anthony Jones - MVP ASP/ASP.NET
    Anthony Jones, Aug 19, 2008
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Shawn
    Replies:
    6
    Views:
    469
    =?Utf-8?B?Q2hyaXM=?=
    Mar 2, 2005
  2. Mohan SRC via .NET 247

    Upload larger files

    Mohan SRC via .NET 247, Mar 24, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    360
    Mohan SRC via .NET 247
    Mar 24, 2005
  3. Mohan SRC via .NET 247

    Upload larger files

    Mohan SRC via .NET 247, Mar 24, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    372
    Tim_Mac
    Mar 24, 2005
  4. Peter Williams
    Replies:
    1
    Views:
    1,381
    Dylan Parry
    Jun 3, 2005
  5. carrzkiss
    Replies:
    0
    Views:
    442
    carrzkiss
    Jan 15, 2009
Loading...

Share This Page