Results 1 to 8 of 8

Thread: [RESOLVED] UpLoadFile With WebBrowser

  1. #1

    Thread Starter
    Addicted Member *PsyKE1*'s Avatar
    Join Date
    Jun 2010
    Location
    Spain
    Posts
    243

    Resolved [RESOLVED] UpLoadFile With WebBrowser

    How I can Upload File with WebBrowser??
    Y have a inputBox and a Button in a website and i if I press the button opens a CommonDialog me to scan the file and put the route on the input ...
    this has to be very easy

    Thanks
    Last edited by *PsyKE1*; Jun 18th, 2010 at 08:39 AM.

  2. #2
    Hyperactive Member
    Join Date
    Sep 2009
    Location
    Lost in thought
    Posts
    349

    Re: UpLoadFile With WebBrowser

    Use the PostData Parameter.
    It's simple AND elegant
    From THE MSDN
    Code:
          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://YourServer" ' A URL that will accept a POST
             Flags = 0
             TargetFrame = ""
    
             PostData = "Information sent to host"
    
             ' VB creates a Unicode string by default so we need to
             ' convert it back to Single byte character set.
             PostData = StrConv(PostData, vbFromUnicode)
    
             Headers = ""
    
             WebBrowser1.Navigate URL, Flags, TargetFrame, PostData, Headers
          End Sub
    Hope this helps
    .

    The answer to your question is Here
    And here
    C:\Program Files\Microsoft Visual Studio\MSDN98\98VSa\1033\SAMPLES\VB98

    Please go to the "Thread Tools" menu at the top of this Thread, and click "Mark Thread Resolved" when you have your answer.
    So I can fine the answer when I need it.

    how to stop the playsound when it is in loop..Play more than 1 sound at a time..
    ini file Check if IP changed Strings 'Split', 'Left' and 'Right'
    Save And Load an Array of list-boxes, to and from a file......list-box and CommonDialog
    Quote Originally Posted by RobDog888

    So please install VB6 service pack 6 as its the latest and last supported service pack MS will ever make.
    http://support.microsoft.com/kb/q198880/ I'm sure this will fix your issue
    The only reason some people get lost in thought is because it’s unfamiliar territory. —Paul Fix

  3. #3

    Thread Starter
    Addicted Member *PsyKE1*'s Avatar
    Join Date
    Jun 2010
    Location
    Spain
    Posts
    243

    Re: UpLoadFile With WebBrowser

    mmmm
    Thanks but I've been looking and can not find what I wanted ...
    This is the code of the web with the need to interact:

    Code:
    <input type="file"		name="archivo" id="idarchivo">
    &nbsp;<br>
    &nbsp;<br>
    
    <input type="submit"	name="enviar" value="Submit-enviar"	onclick="alert('ok1')">
    &nbsp;<br>
    &nbsp;<br>
    Y use this but it doesn't works:
    Code:
        WebBrowser1.Document.All("archivo").Value = "C:\File.txt"
        WebBrowser1.Document.All("enviar").Click
    What am I doing wrong?

    Thanks!

  4. #4
    Lively Member _-Rs-_'s Avatar
    Join Date
    Aug 2009
    Posts
    84

    Re: UpLoadFile With WebBrowser

    Quote Originally Posted by *PsyKE1* View Post
    mmmm
    Thanks but I've been looking and can not find what I wanted ...
    This is the code of the web with the need to interact:

    Code:
    <input type="file"		name="archivo" id="idarchivo">
    &nbsp;<br>
    &nbsp;<br>
    
    <input type="submit"	name="enviar" value="Submit-enviar"	onclick="alert('ok1')">
    &nbsp;<br>
    &nbsp;<br>
    Y use this but it doesn't works:
    Code:
        WebBrowser1.Document.All("archivo").Value = "C:\File.txt"
        WebBrowser1.Document.All("enviar").Click
    What am I doing wrong?

    Thanks!
    Yep that will not work instead you can use the sendkeys function

    vb Code:
    1. wb1.Document.All.Item("archivo").Focus
    2. SendKeys "C:\test.txt"

    Something like that


  5. #5
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: UpLoadFile With WebBrowser

    afaik you can not automate a file input
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  6. #6

    Thread Starter
    Addicted Member *PsyKE1*'s Avatar
    Join Date
    Jun 2010
    Location
    Spain
    Posts
    243

    Re: UpLoadFile With WebBrowser

    @_-Rs-_
    It works!!
    Thanks, but are you sure it's the best way to do it??
    So I can't do otherwise than with SendKeys?

    Thanks again

  7. #7
    Lively Member _-Rs-_'s Avatar
    Join Date
    Aug 2009
    Posts
    84

    Re: UpLoadFile With WebBrowser

    Quote Originally Posted by *PsyKE1* View Post
    @_-Rs-_
    It works!!
    Thanks, but are you sure it's the best way to do it??
    So I can't do otherwise than with SendKeys?

    Thanks again
    Well bro it's true SendKeys has lot of issues may not be reliable at all

    But it's up to you what functions or controls you prefer to use

    But there are other ways to do this aswell like using winsock , Inet ect..

    Or using other VB functions

    EDIT: Dont forget to mark the thread as SOLVED if you found what your looking for
    Last edited by _-Rs-_; Jun 18th, 2010 at 08:31 AM.


  8. #8

    Thread Starter
    Addicted Member *PsyKE1*'s Avatar
    Join Date
    Jun 2010
    Location
    Spain
    Posts
    243

    Re: UpLoadFile With WebBrowser

    Thanks!
    RESOLVED

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