Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Filling in <input type="file" field using webbrowser control

Posted on 2011-02-19
18
1,648 Views
Last Modified: 2012-05-11
I am trying to make an app to help automate some daily tasks on my website, I have everything set to automatically fill in data in the text fields and drop down boxes but I am having a lot of difficulty with the <input type="file" field, I've seen it mentioned that sendkeys should work with it but I have been unsuccessful doing that. Is there some kind of workaround for this? I really could use some help with this - Thanks!

&#9;&#9;<div class="tab-page" id="step2"> 
&#9;&#9;&#9;&#9;<h4 class="tab">2. Images</h4> 
&#9;&#9;&#9;&#9;<table cellpadding="5"> 
&#9;&#9;&#9;&#9;<tr> 
&#9;&#9;&#9;&#9;&#9;<td><b>Add a new image to this product</b></td> 
&#9;&#9;&#9;&#9;</tr> 
&#9;&#9;&#9;&#9;</table> 
&#9;&#9;&#9;&#9;<hr style="width:100%;" /><br /> 
&#9;&#9;&#9;&#9;<table cellpadding="5" style="width:100%"> 
&#9;&#9;&#9;&#9;&#9;<tr> 
&#9;&#9;&#9;&#9;&#9;&#9;<td class="col-left">File:</td> 
&#9;&#9;&#9;&#9;&#9;&#9;<td style="padding-bottom:5px;"> 
&#9;&#9;&#9;&#9;&#9;&#9;&#9;<input type="file" id="image_product" name="image_product" /> 
&#9;&#9;&#9;&#9;&#9;&#9;&#9;<p>Format: JPG, GIF, PNG<br />Filesize: 2000Kb max.</p> 
&#9;&#9;&#9;&#9;&#9;&#9;</td> 

Open in new window


Using VB 2008
0
Comment
Question by:battleweb
  • 8
  • 4
  • 3
  • +1
18 Comments
 
LVL 13

Expert Comment

by:George K.
ID: 34934303
This is not possible due to security.- cannot be done.
Imagine a web site able to get any file on a user computer.
0
 

Author Comment

by:battleweb
ID: 34934347
I've read that many times, but I'm sure there is some sort of work around for this - (ie. change the element in the source to "text", ad the location of the file then change it back to "file" or maybe using a passthrough server where the html is changed on the way back to the server to contain the path of the file - something). The reason I believe there is a work around is because I've seen many automated browser apps actually work around that issue, so there are work arounds and I am looking for a work around.
0
 
LVL 13

Expert Comment

by:George K.
ID: 34934379
Maybe you could use  an upload directory once of course it is on your home server.

Have also a lookt at iMacros  for Firefoxhttps://addons.mozilla.org/en-US/firefox/addon/imacros-for-firefox/
0
How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

 
LVL 13

Expert Comment

by:George K.
ID: 34934400
as a workaround:

<input type="file" id="myfile" onchange="document.getElementById('myfile').value=this.value" />
<input type="text" id="textname" />

.
.
.
0
 

Author Comment

by:battleweb
ID: 34934427
georgekl,
   It all has to be contained in my app (third party browser etc won't work for what I'm trying to achieve). I'm not understanding your last post - it is my own server, I am trying to interact with a third party php script, I wouldnt begin to know where and what to change in it, so if I can change the page source in my webbrowser control or via a pass through server, that'd be ideal.
0
 
LVL 26

Expert Comment

by:EddieShipman
ID: 34955186
What you have to do is post your form outside of the webrowser control using something like XMLHTTP and make sure the form is multi/part encoded.
I've done this before with Delphi but not in VB.Net.
0
 

Author Comment

by:battleweb
ID: 34956383
Eddie,
  Thank you for your suggestion, but as I had mentioned, The WB control must be used due to the nature of the program. However, I am open to workarounds which will allow me to hide the file input box or place it outside of the screen area and then be filled - as long as it is out of view.
0
 
LVL 26

Expert Comment

by:EddieShipman
ID: 34957433
It can be done without the user even knowing by using XMLHTTP in Javascript. You just have to make sure the form is built correctly before posting.
0
 

Author Comment

by:battleweb
ID: 34967851
EddieShipman - that's basically the same as saying "it can be done" and not giving any info as to how - that doesnt help. Besides, the workaround needs to be done within my VB.net application, not server side.
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 35021768
For the following solution, you would have to download the html and add the javascript to it before showing in WB

http://www.experts-exchange.com/Programming/Languages/.NET/Visual_Basic.NET/Q__25216919.html
0
 
LVL 26

Expert Comment

by:EddieShipman
ID: 35021823
What you do is take the info and file that you want to send and form an XMLHTTP request and post it to the URL that you want to send it to all in javascript or jQuery ajax.
How difficult its that?
0
 

Author Comment

by:battleweb
ID: 35023897
EddieShipman, are you kidding me? What part of this question says I know anything about "XMLHTTP", javascript or jQuery ajax? You don't provide a solution or example and expect me to know exactly what the heck you are talking about. I am a VB programmer only. Do me a favor, quit posting here, you have used up far too much of my time.
0
 

Author Comment

by:battleweb
ID: 35023902
CodeCruiser - can you give me an example of how that would work - I am not familiar with javascript and from what I seen in that post, it merely clears a field, but does not fill in the file location in the file field.
0
 
LVL 26

Expert Comment

by:EddieShipman
ID: 35024095
Well, you must not be a very good VB programmer if you know nothing about XMLHTTP.
I'll leave you alone because you are wasting MY time.
0
 

Accepted Solution

by:
battleweb earned 0 total points
ID: 35160746
I have been unable to obtain any useful information, but have been openly insulted. This question needs to be closed.
0
 

Author Closing Comment

by:battleweb
ID: 35187462
No solution provided.
0

Featured Post

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Generate Numbers in JQuery file 11 66
Finding the IIS version 5 21
Programming Language for Wordpress 7 33
Make a website not indexable by google 6 13
Developer portfolios can be a bit of an enigma—how do you present yourself to employers without burying them in lines of code?  A modern portfolio is more than just work samples, it’s also a statement of how you work.
Does your audience prefer people in photos or no people? How can you best highlight what you’re selling? What are your competitors doing, and what can you do that is different and unique from them?  Continue reading to learn how to make your images …
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question