Link to home
Start Free TrialLog in
Avatar of brookman
brookman

asked on

webbrowser problem

I hope someone out there is as twisted as me.

I know the webbrowser control pretty well. or so I thought until now.

<html>
<body>
<INPUT name=PICTURE1_SOURCE size=50 type=file accept="image/jpeg,image/jpg">
</body>
</html>

how do I programtically(from VB) set the value of this box. No .value does not work.



ASKER CERTIFIED SOLUTION
Avatar of djbusychild
djbusychild

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of djbusychild
djbusychild

this is really a VB question not a javascript question.

normally you wouldn't be able to since it'd be a security risk for javascript to set that and automatically upload random files from the user.


Now if you're overriding that through your own extended version of the webbrowser control, then you could try querying for the IHTMLDocument2 interface, then run get_forms on the interface, iterate through the IHTMLElementCollection interface you get back through the item() method until you find your file input then run set_value() on it... This is coming from the C++ point of view, I don't speak VB so this could potentially be a hell a lot easier through VB... dunno..

you might even be able to query for the IHTMLInputFileElement interface directly
oops... sorry I accidentally made that an answer. =(
This site is quite good. It provides whole source code of the file uploading function with comment. The whole function is written in VBScript and no need to register the com object.

I have used this before and it worked fine.

http://www.aspzone.com/articles/john/aspUpload/

good luck.
You can use this to display the image which is uploaded by user.

<%
If Request.TotalBytes > 0 Then
  Response.BinaryWrite(Request.BinaryRead(Request.TotalBytes))
End If
%>

The code is copied from the link in previous comment.
Vincet, I think you're misunderstanding the question
Avatar of brookman

ASKER

I have had this problem solved.  I ended up doing an object.focus then use sendkeys to fill in the box.
I solved this in a different way but I appreciate your effort.