Why doesnt doesnt HTML input of type file not work with Ajax update panel

Posted by Sean P on Stack Overflow See other posts from Stack Overflow or by Sean P
Published on 2010-04-29T22:27:57Z Indexed on 2010/04/29 22:37 UTC
Read the original article Hit count: 283

I have a input of type file and when i try to do a Request.files when the input is wrapped in an update panel...it always returns an empty httpfilecollection. Why???

This is the codebehind: (At HttpContext.Current.Request.Files...its always 0 for the count.)

 Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
    Dim uploads As HttpFileCollection
    uploads = HttpContext.Current.Request.Files

    For i As Integer = 0 To (uploads.Count - 1)

        If (uploads(i).ContentLength > 0) Then
            Dim c As String = System.IO.Path.GetFileName(uploads(i).FileName)

            Try
                uploads(i).SaveAs("C:\UploadedUserFiles\" + c)
                Span1.InnerHtml = "File Uploaded Sucessfully."
            Catch Exp As Exception
                Span1.InnerHtml = "Some Error occured."
            End Try

        End If

    Next i

End Sub

This example comes from the ASP.Net website...but my application is very similar.

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about .NET