473,549 Members | 2,663 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to set value of <INPUT type=file...> element programmaticall y?

Hi ALL.

I need to simulate send POST data ( - file upload) as it was submitted in Browser. In C# I create instanse of IE, navigate to page with the form, fill in the fields and try to Submit by call submitButton.cl ick() Unfortunately it does not work while file_filed.vale = <path_to_file > has no effect, value <INPUT type=file...> cound not be set from script of that HTML page. Is there another way to set that value by means of ..NET ? Below the part of code :

SHDocVw.Interne tExplorer ie = new SHDocVw.Interne tExplorerClass( );
object o = null;
ie.Navigate( url, ref o, ref o, ref o, ref o ); // navigate to page with the form and waiting for DownloadComplet e
............... ............... ............... .
mshtml.HTMLDocu ment doc = (mshtml.HTMLDoc ument)ie.Docume nt;
mshtml.IHTMLInp utFileElement file = (mshtml.IHTMLIn putFileElement) doc.getElements ByName("file"). item(null,0);
file.value = m_sPathToFile; // has no effect!!!!!!!
mshtml.HTMLInpu tButtonElement btn = (mshtml.HTMLInp utButtonElement )doc.getElement sByName("send") .item(null,0);
btn.click();

............... ..........

Thank you for any help

Evgeny

Nov 16 '05 #1
2 28347
"Evgeny Zoldin" <zo****@hotmail .com> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl
I need to simulate send POST data ( - file upload) as it was
submitted in Browser. In C# I create instanse of IE, navigate to page
with the form, fill in the fields and try to Submit by call
submitButton.cl ick() Unfortunately it does not work while
file_filed.vale = <path_to_file > has no effect, value <INPUT
type=file...> cound not be set from script of that HTML page. Is
there another way to set that value by means of .NET ?


There is no way to set the value programmaticall y, with .NET or
otherwise, for security reasons. value property on <input type="file">
element is read-only.
--
With best wishes,
Igor Tandetnik

"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken
Nov 16 '05 #2
Hi,
It can't be done programmaticall y; user has to manually select the file for
uploading.

"Evgeny Zoldin" <zo****@hotmail .com> wrote in message
news:#v******** ******@TK2MSFTN GP09.phx.gbl...
Hi ALL.

I need to simulate send POST data ( - file upload) as it was submitted in
Browser. In C# I create instanse of IE, navigate to page with the form, fill
in the fields and try to Submit by call submitButton.cl ick() Unfortunately
it does not work while file_filed.vale = <path_to_file > has no effect, value
<INPUT type=file...> cound not be set from script of that HTML page. Is
there another way to set that value by means of .NET ? Below the part of
code :

SHDocVw.Interne tExplorer ie = new SHDocVw.Interne tExplorerClass( );
object o = null;
ie.Navigate( url, ref o, ref o, ref o, ref o ); // navigate to page with the
form and waiting for DownloadComplet e

............... ............... ............... .

mshtml.HTMLDocu ment doc = (mshtml.HTMLDoc ument)ie.Docume nt;
mshtml.IHTMLInp utFileElement file =
(mshtml.IHTMLIn putFileElement) doc.getElements ByName("file"). item(null,0);
file.value = m_sPathToFile; // has no effect!!!!!!!
mshtml.HTMLInpu tButtonElement btn =
(mshtml.HTMLInp utButtonElement )doc.getElement sByName("send") .item(null,0);
btn.click();
............... ..........

Thank you for any help
Evgeny
Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2580
by: chirs | last post by:
Hi, I want to put a value in a cookie. The following code does not work. It does not store the box1.value in the cookie. How can I fix it? <input type="text" name="box1" onblur=document.cookie="user=" + box1.value> Chris
4
21274
by: Martin Lucas-Smith | last post by:
I am wanting to know whether are XHTML1-valid characters for use within an id attribute and/or a name attribute. http://validator.w3.org/check?uri=http://www-thaihydro.geog.cam.ac.uk/riverslice/&ss=1&verbose=1 (e.g. see line 77) suggests that it is valid, but the spec suggests that it is not. More detail:
2
5949
by: not 2 swift | last post by:
I thought I would update an old page on which I had used a <INPUT TYPE=image ...> with a <BUTTON><IMG SRC=...></BUTTON> The problem is that <BUTTON> always provides a shadow/emboss effect. Can I get rid of that? If the old <INPUT> button has been deprecated in favor of <BUTTON>, have all it's button functions been duplicated? Thanks...
3
12186
by: iinet | last post by:
How can i set in my css a min width for input elements, but leave the max size dynamic? Ben
3
13129
by: TR | last post by:
Is it possible with CSS to prevent this wrapping alignment with a checkbox with a nested label? This is the label of the checkbox that wraps beneath it I'd prefer it looked like this, with a flush left margin:
10
3066
by: Brian Henry | last post by:
Hi, I am having a problem with an attachment system I made... it works with files up to ~3MB in size then after that if you try to upload a file it just goes to a "Page can not be displayed" page like it tried to do it but errored... I thought changeing the max size for the file input box to about 100mb would fix it but nope here is my page...
5
2235
by: Bart van Deenen | last post by:
Hi all I have a form with a couple of input fields, embedded within spans. I am using script.aculo.us for dragging and dropping, and want to reorder the input fields that way. The input fields are display:inline because I want them all on the same line. Does anyone know of a smart trick to be able to drag these input fields? Just setting...
2
5288
by: Mara Guida | last post by:
Hi, After I've populated a page with some <INPUT ...> elements I'd like to have access to whatever is written there. The best I've done (which does not work) is: ================ // ==UserScript== // @name AddInput
1
2527
by: JPhilS | last post by:
Hi to all Webmaster! I have discover this problem when I inserted the scores of the students i a centain subject. I am making a school project with regards to saving students' record. first, I have to view all students under the certain subject and at the last field, I putted a form to put the scores of each student. say '<input...
1
5493
by: test9991014 | last post by:
Hi folks, I've got something like this: <table> <tr> <td>1</td> <td align=center> <input type=text> </td>
0
7451
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7720
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7960
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7475
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7812
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6048
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5089
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
1061
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
766
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.