• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 349
  • Last Modified:

using multiple fileuploads causing crash


I have the following function below.

When I only select a file from one of my 3 fileupload controls it works fine but if I select more than one I just get a crash but no error, as in my screen shot. The html is as follows:
<asp:FileUpload ID="fupImage" runat="server"  /> <asp:FileUpload ID="fupImage1" runat="server"  /> <asp:FileUpload ID="fupImage2" runat="server"  /><asp:Button ID="btnSaveImage" runat="server" Text="Upload" />

Protected Sub btnSaveImage_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSaveImage.Click

        Dim fileName As String = ""
        Dim reviewerEmail As String = ""

            reviewerEmail = HelperGeneral.GetContentByCode(Common.PageLocation.ImageReviewerEmail).WebsiteText

            If fupImage.HasFile Then                
                fileName = Guid.NewGuid.ToString & Path.GetExtension(fupImage.FileName)
                fupImage.SaveAs(HttpContext.Current.Server.MapPath("~/pendingreview/" & fileName))

                'SendingEmail(fileName, reviewerEmail)
            End If

            If fupImage1.HasFile Then
                fileName = Guid.NewGuid.ToString & Path.GetExtension(fupImage1.FileName)
                fupImage1.SaveAs(HttpContext.Current.Server.MapPath("~/pendingreview/" & fileName))

                'SendingEmail(fileName, reviewerEmail)
            End If

            If fupImage2.HasFile Then
                fileName = Guid.NewGuid.ToString & Path.GetExtension(fupImage2.FileName)
                fupImage2.SaveAs(HttpContext.Current.Server.MapPath("~/pendingreview/" & fileName))

                'SendingEmail(fileName, reviewerEmail)
            End If

            JavascriptAlert("Your new image(s) will appear on the site if deemed suitable by our reviewers. Check back soon to see it live.")
        Catch ex As Exception
            Audit("Public website Error - Image submitted for review and errored.", Common.AuditType.Public_Website_Error, "website")
        End Try

Open in new window

  • 2
2 Solutions
Ajay SharmaCommented:
May be your are trying to upload files more than 4 MB in total.
If the sum of files sizes is more than 4 MB then asp.net process will not respond.

You need to modify your web.config, add maxRequestLength property in the httpRuntime node in web.config as belows:

<httpRuntime maxRequestLength="10240" />

The size needs to be mentioned in KBs, the above can handle 10 MB of post data.
scm0smlAuthor Commented:
Ah that sounds about right actually.

I will make this change later and get back to you.

p.s.   you can turn off pretty errors in IE to show what is actually happenning.

go to tool > internet options > Advanced tab

uncheck 'Show friendly HTTP error messages'
scm0smlAuthor Commented:
Spot on.

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now