Results 1 to 3 of 3

Thread: Webrowser - avoid using "browse file" dialog

  1. #1

    Thread Starter
    Hyperactive Member Krass's Avatar
    Join Date
    Aug 2000
    Location
    Montreal
    Posts
    489

    Webrowser - avoid using "browse file" dialog

    My VB6 app has a webbrowser and loads up a webpage. One of the elements on that page is a "browse for local picture and upload" button (inp.type = "file"). Those that you click and then browse for an image on your computer and then submit the form.

    I want to automate that process, which was done the following way:
    Code:
    Web.Document.All("mandatory_picture").focus
    SendKeys "C:\020.jpg"
    That works nice but requires focus and maximized form to work. Would there be away to do it "stealth"?

    I tried the following:

    Code:
    Web.Document.Forms(1).elements(9).Value = "C:\020.jpg"
    
    With Web.Document.All
    .Item("mandatory_picture").Value = "C:\020.jpg"
    End With
    I also tried setting the inp.value of the right element:
    Code:
    inp.Value = "C:\test\020.jpg"
    ...because that's what the value for that element shows up when the file is browsed 'normally' from the web page - but it seems I wasn't able to 'set' anything using "inp.value"...

    Thank for any input
    Chris

  2. #2
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Webrowser - avoid using "browse file" dialog

    if this is a browse / file upload button. you cannot automate it (security feature)
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  3. #3
    Frenzied Member wpearsall's Avatar
    Join Date
    Feb 2002
    Location
    England / UK
    Posts
    1,065

    Re: Webrowser - avoid using "browse file" dialog

    Quote Originally Posted by Static View Post
    if this is a browse / file upload button. you cannot automate it (security feature)
    you can however use the internet TRANSFER control to upload the file directly to the server - and get the response... by sending the file in the headers as a multipart/formdata content... i will try find the code i used on my app later if you want... - im assuming the server already handles the file upload though yes?


    [edit=did a quick search and...]
    http://www.vbforums.com/showthread.php?t=337424
    this gives you code to upload a file to a PHP script [even supplies the php script if you dont have one] and uses Winsock [i believe]

    and the search "HTTP File Upload":
    http://www.vbforums.com/search.php?searchid=2248260

    lots of other threads
    HTHs ya
    Last edited by wpearsall; Sep 29th, 2009 at 05:34 PM.
    Wayne

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