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
Re: Webrowser - avoid using "browse file" dialog
if this is a browse / file upload button. you cannot automate it (security feature)
Re: Webrowser - avoid using "browse file" dialog
Quote:
Originally Posted by
Static
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 :)