Upload files with HTTPWebrequest (multipart/form-data)

后端 未结 21 2512
独厮守ぢ
独厮守ぢ 2020-11-21 04:53

Is there any class, library or some piece of code which will help me to upload files with HTTPWebrequest?

Edit 2:

I do not

21条回答
  •  天命终不由人
    2020-11-21 05:11

    I had to deal with this recently - another way to approach it is to use the fact that WebClient is inheritable, and change the underlying WebRequest from there:

    http://msdn.microsoft.com/en-us/library/system.net.webclient.getwebrequest(VS.80).aspx

    I prefer C#, but if you're stuck with VB the results will look something like this:

    Public Class BigWebClient
        Inherits WebClient
        Protected Overrides Function GetWebRequest(ByVal address As System.Uri) As System.Net.WebRequest
            Dim x As WebRequest = MyBase.GetWebRequest(address)
            x.Timeout = 60 * 60 * 1000
            Return x
        End Function
    End Class
    
    'Use BigWebClient here instead of WebClient
    

提交回复
热议问题