plz帮助winttp图片上传代码不起作用.. [英] plz help winttp image upload code not work ..

查看:110
本文介绍了plz帮助winttp图片上传代码不起作用..的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Public Function InvenImageUpload(ByVal path As String) As String

        Dim ImageBinary() As Byte
        ImageBinary = IO.File.ReadAllBytes(Filepath.Text)
        Dim Header1 As String, Header2 As String
        wbody = TextBox1.Text
        Header1 = System.Text.UnicodeEncoding.GetChars(Split(wBody, "wBinary")(0))
        Header2 = System.Text.UnicodeEncoding.GetChars(Split(wBody, "wBinary")(1))

        Dim BHeader1() As Byte, BHeader2() As Byte, Buffer() As Byte
        BHeader1 = System.Text.Encoding.UTF8.GetBytes(Header1)
        BHeader2 = System.Text.Encoding.UTF8.GetBytes(Header2)

        Dim DS As New MemoryStream
        DS.Write(BHeader1, 0, BHeader1.Length)
        DS.Write(ImageBinary, 0, ImageBinary.Length)
        DS.Write(BHeader2, 0, BHeader2.Length)

        DS.Position = 0
        ReDim Buffer(DS.Length)
        DS.Read(Buffer, 0, Buffer.Length) : DS.Close()

        With winhttp
            .Open("POST", "http://imgdb.kilho.net/upload.php")
            .SetRequestHeader("Content-Type", "multipart/form-data; boundary=----------1877296668268")
            .SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0")
            .SetRequestHeader("Host", "http://image.kilho.net/")
            .SetRequestHeader("Content-Length", UBound(Buffer))
            .Send(Buffer)

            .WaitForResponse() : Application.DoEvents()
            ' Headers = .GetAllResponseHeaders
            MsgBox(.ResponseText)
        End With

    End Function





i want http://imgdb.kilho.net/upload.php上传我的照片.. plz帮助 [ ^ ]

推荐答案

请停止发布相同的问题。不要让人们从古代语言中转换大量文件发布代码,只需学习如何通过POST以目标语言提交文件并相应地使用代码。



.net - 如何发布文件通过vb.net中的HTTP帖子 - Stack Overflow [ ^ ]



WebClient.UploadFile方法(字符串,字符串)(System.Net) [ ^ ]



但是,这仍然无法帮助您无法访问其URL。您需要联系任何支持该网站的人,以获得帮助。您可能需要在请求中发送特定标头。
Please stop posting the same question. Rather than asking people to convert reams of variations of file posting code from ancient languages, just learn how to submit a file via POST in your target language and use the code accordingly.

.net - How to post a file via HTTP post in vb.net - Stack Overflow[^]

WebClient.UploadFile Method (String, String) (System.Net)[^]

However this still isn't going to help with the fact that you don't have access to their URL. You'll need to contact whoever supports the site for help with that. It could be you need to send specific headers in the request.


这篇关于plz帮助winttp图片上传代码不起作用..的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆