external fileupload window, programmically input path and file, then h

  • (2 Pages)
  • +
  • 1
  • 2

23 Replies - 2435 Views - Last Post: 23 July 2012 - 06:56 AM Rate Topic: -----

#1 solarissf  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 35
  • Joined: 27-March 12

external fileupload window, programmically input path and file, then h

Posted 19 July 2012 - 04:14 PM

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!!

Is This A Good Question/Topic? 0
  • +

Replies To: external fileupload window, programmically input path and file, then h

#2 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3662
  • View blog
  • Posts: 11,466
  • Joined: 05-May 12

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
Was This Post Helpful? 0
  • +
  • -

#3 solarissf  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 35
  • Joined: 27-March 12

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?
Was This Post Helpful? 0
  • +
  • -

#4 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6107
  • View blog
  • Posts: 23,661
  • Joined: 23-August 08

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
Was This Post Helpful? 0
  • +
  • -

#5 solarissf  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 35
  • Joined: 27-March 12

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?
Was This Post Helpful? 0
  • +
  • -

#6 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3662
  • View blog
  • Posts: 11,466
  • Joined: 05-May 12

Re: external fileupload window, programmically input path and file, then h

Posted 20 July 2012 - 07:43 AM

Sorry, attachment seems to be missing.
Was This Post Helpful? 0
  • +
  • -

#7 solarissf  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 35
  • Joined: 27-March 12

Re: external fileupload window, programmically input path and file, then h

Posted 20 July 2012 - 07:45 AM

hopefully this works

Attached File(s)


Was This Post Helpful? 0
  • +
  • -

#8 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3662
  • View blog
  • Posts: 11,466
  • Joined: 05-May 12

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.
Was This Post Helpful? 0
  • +
  • -

#9 solarissf  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 35
  • Joined: 27-March 12

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?
Was This Post Helpful? 0
  • +
  • -

#10 solarissf  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 35
  • Joined: 27-March 12

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
Was This Post Helpful? 0
  • +
  • -

#11 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3662
  • View blog
  • Posts: 11,466
  • Joined: 05-May 12

Re: external fileupload window, programmically input path and file, then h

Posted 20 July 2012 - 09:03 AM

View Postsolarissf, on 20 July 2012 - 08:47 AM, said:

I'm completely lost looking for the correct form. How do I show you the actual source of the page to make this easier?


My problem exactly. In the end, I just opened the .htm file in an isolated VM just in case the .htm file has "cooties".
Was This Post Helpful? 0
  • +
  • -

#12 solarissf  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 35
  • Joined: 27-March 12

Re: external fileupload window, programmically input path and file, then h

Posted 20 July 2012 - 09:04 AM

sorry... say what?
Was This Post Helpful? 0
  • +
  • -

#13 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3662
  • View blog
  • Posts: 11,466
  • Joined: 05-May 12

Re: external fileupload window, programmically input path and file, then h

Posted 20 July 2012 - 09:06 AM

View Postsolarissf, 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&amp;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

Was This Post Helpful? 0
  • +
  • -

#14 solarissf  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 35
  • Joined: 27-March 12

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&amp;USERID=X152169
?

And I try and use that in HttpWebRequest?
http://stackoverflow...ipart-form-data
Was This Post Helpful? 0
  • +
  • -

#15 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3662
  • View blog
  • Posts: 11,466
  • Joined: 05-May 12

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 "&amp;".

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

Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2