Hello All,
I'm using c# winform. Using webbrowser.control I have logged into a website and navigated around to a particular section. Now I get to the part where I want to upload a file. I am able to "HIT" the UPLOAD button on this website, and the BROWSE button. A normal FileUpload box pops up...
any idea how I can enter in the path and filename into the box, and hit OK all using code?
I hope I am explaining clear... the pop up window is in front of me, now I want to select the file in code.
Thanks in advance!!
23 Replies - 901 Views - Last Post: 23 July 2012 - 06:56 AM
#1
external fileupload window, programmically input path and file, then h
Posted 19 July 2012 - 04:14 PM
Replies To: external fileupload window, programmically input path and file, then h
#2
Re: external fileupload window, programmically input path and file, then h
Posted 19 July 2012 - 09:17 PM
If you know the URL the file gets posted to, you don't even need to play with the WebBrowserControl. You can use HttpWebRequest.
Here's a few answers to a question about how to do the upload: http://stackoverflow...ipart-form-data
Here's a few answers to a question about how to do the upload: http://stackoverflow...ipart-form-data
#3
Re: external fileupload window, programmically input path and file, then h
Posted 20 July 2012 - 05:05 AM
Thanks for helping, how can I find the URL the file gets posted to?
#4
Re: external fileupload window, programmically input path and file, then h
Posted 20 July 2012 - 05:37 AM
Look in the HTML source for the form's action
#5
Re: external fileupload window, programmically input path and file, then h
Posted 20 July 2012 - 06:11 AM
I've attached the source code. I'm guessing when the user manually hits loadbutton, it launches the function FileUpload1_Click. Sorry for the lame questions but as you can see I'm really new to this. Do you see the URL anywhere on here? It also seems to have some type of validator to check data is in proper format. Am I still on the correct path here?
#6
Re: external fileupload window, programmically input path and file, then h
Posted 20 July 2012 - 07:43 AM
Sorry, attachment seems to be missing.
#7
Re: external fileupload window, programmically input path and file, then h
Posted 20 July 2012 - 07:45 AM
hopefully this works
Attached File(s)
-
source.htm (137.07K)
Number of downloads: 44
#8
Re: external fileupload window, programmically input path and file, then h
Posted 20 July 2012 - 08:23 AM
Ack... I was hoping that source.htm was the actual source of the page, not an HTML rendering of the source of the page.
Anyway, look for the <form> element that encapsulates <input type="file">. The action attribute of the <form> element should contain the URL.
Anyway, look for the <form> element that encapsulates <input type="file">. The action attribute of the <form> element should contain the URL.
#9
Re: external fileupload window, programmically input path and file, then h
Posted 20 July 2012 - 08:47 AM
I'm completely lost looking for the correct form. How do I show you the actual source of the page to make this easier?
#10
Re: external fileupload window, programmically input path and file, then h
Posted 20 July 2012 - 08:54 AM
just so you have the big picture. The window I currently have is in my webbrowser.control, and it is a file upload screen. So if I were to hit the LOADTRADES BUTTON, it comes back with a popup, that says, "are you sure", then I hit YES. And it uploads to server
#11
Re: external fileupload window, programmically input path and file, then h
Posted 20 July 2012 - 09:03 AM
#12
Re: external fileupload window, programmically input path and file, then h
Posted 20 July 2012 - 09:04 AM
sorry... say what?
#13
Re: external fileupload window, programmically input path and file, then h
Posted 20 July 2012 - 09:06 AM
solarissf, on 20 July 2012 - 08:54 AM, said:
just so you have the big picture. The window I currently have is in my webbrowser.control, and it is a file upload screen. So if I were to hit the LOADTRADES BUTTON, it comes back with a popup, that says, "are you sure", then I hit YES. And it uploads to server
Based on what I saw on the .htm, it's just a Javascript validator that brings up that prompt. They don't actually do any AJAX upload of files, so it follows the standard web semantics for file uploads using an <input type="file" ...>. That means it uses the URL from the <form> element. http://wwww.w3school...s/tag_input.asp
Here is the form line:
<form name="form1" method="post" action="FileLoad.aspx?COMPANYNAME=ALL+KEYED+DATA&USERID=X152169" onsubmit="javascript:return WebForm_onsubmit();" id="form1" enctype="multipart/form-data">
This post has been edited by Skydiver: 20 July 2012 - 09:07 AM
#14
Re: external fileupload window, programmically input path and file, then h
Posted 20 July 2012 - 09:12 AM
so that means the URL is
FileLoad.aspx?COMPANYNAME=ALL+KEYED+DATA&USERID=X152169
?
And I try and use that in HttpWebRequest?
http://stackoverflow...ipart-form-data
FileLoad.aspx?COMPANYNAME=ALL+KEYED+DATA&USERID=X152169
?
And I try and use that in HttpWebRequest?
http://stackoverflow...ipart-form-data
#15
Re: external fileupload window, programmically input path and file, then h
Posted 20 July 2012 - 09:47 AM
You'll have to prepend the URL on which the form is on.
You'll also have to unencode that "&".
Something like:
You'll also have to unencode that "&".
Something like:
http://makemerichovernight.com/FileLoad.aspx?COMPANYNAME=ALL+KEYED+DATA&USERID=X152169
This post has been edited by Skydiver: 20 July 2012 - 09:48 AM
|
|

New Topic/Question
Reply



MultiQuote





|