Results 1 to 4 of 4

Thread: How do I post data in webbrowser1 ?

  1. #1

    Thread Starter
    Fanatic Member newprogram's Avatar
    Join Date
    Apr 2006
    Location
    in your basement
    Posts
    769

    Exclamation How do I post data in webbrowser1 ?

    I'm using this to post data to my server from my vb6 app I post data fine but i can't send a image to my server I work fine on my website "on a html page" and upload the image to my server with out problem but i would like to do it from my app. here my v6 code
    Private Sub Command1_Click()
    Dim URL As String
    Dim Flags As Long
    Dim TargetFrame As String
    Dim PostData() As Byte
    Dim Headers As String
    URL = "http://myserver.com/" ' A URL that will accept a POST
    Flags = 0
    TargetFrame = ""
    PostData = "function=pic2&username=jct&password=ram4&pict=temp.gif&pict_to=0&pict_type=0"
    PostData = StrConv(PostData, vbFromUnicode)
    Headers = "Content-Type: application/x-www-form-urlencoded" & _
    vbCrLf
    WebBrowser1.Navigate URL, Flags, TargetFrame, PostData, Headers

    End Sub

    here my html code

    <html>
    <head>

    </head>
    <body>
    <form
    method="POST"
    action="http://mywebserver.com/"
    enctype="multipart/form-data">
    <input type="hidden" name="function" value="pict2">
    <input type="text" name="username" value="jct">
    <input type="text" name="password" value="ram4">
    <input type="file" name="pict">
    <input type="text" name="pict_to" value="0">
    <input type="text" name="pict_type" value="0">

    <input type="submit" value="Send" id="upload pic">
    </form>
    </body>
    </html>

    so basically I want my vb6 app to do what this html page .
    Live life to the fullest!!

  2. #2

    Thread Starter
    Fanatic Member newprogram's Avatar
    Join Date
    Apr 2006
    Location
    in your basement
    Posts
    769

    Re: How do I post data in webbrowser1 ?

    anyone? is this possible to post a image using the webbrowser control?
    Live life to the fullest!!

  3. #3
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,532

    Re: How do I post data in webbrowser1 ?

    Quote Originally Posted by newprogram View Post
    anyone? is this possible to post a image using the webbrowser control?
    IT's not that easy... and it's not that easy for a reason... If it was then anyone could create a website, then create an app with a WB and scrape files off anyone's computer w/o them knowing. It would be a security nightmare. Your value for pic in the post data is incorrect. It isn't going to be the file name... it would actually be the file itself. But again it's not that simple, as there's other data to go along with it: name, size, etc. But... I don't think it's possible to post a file in the first place like this because it would be a security issue if you could... I also think that's the wrong content type header to use when posting files. Not sure though.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  4. #4
    Fanatic Member
    Join Date
    Apr 2017
    Posts
    554

    Re: How do I post data in webbrowser1 ?

    WebBrowser is a browser and browsers do not upload data to a website unless there is some application on the server to allow uploading in which case it is not the browser that does the uploading. I'm assuming the website is your website so if it is then consider using FTP to upload.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width