0

我有一个文件类型的输入,当我尝试在输入包含在更新面板中时执行 Request.files 时......它总是返回一个空的 httpfilecollection。为什么???

这是代码隐藏:(在 HttpContext.Current.Request.Files ......计数始终为 0。)

 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

此示例来自 ASP.Net 网站...但我的应用程序非常相似。

4

1 回答 1

4

看看这个文件上传和更新面板

于 2010-04-29T22:33:46.040 回答