Welcome Guest Search | Active Topics | Sign In | Register

Upload file Options
AiSatan
Posted: Friday, May 13, 2016 5:00:14 AM
Rank: Advanced Member
Groups: Member

Joined: 2/11/2016
Posts: 35
Is there a solution for file upload?
I can catch the file upload window and send any file, but for call it is necessary to press on a input-file control, like this:

Code: HTML/ASPX
<input type="file" name="f">


It can not be pressed using js due to security reasons, can I click it by your code? or maybe there are other solutions to upload file without user action (but, if it needed, with permissions from him)?

I will be grateful for any solution.
eo_support
Posted: Friday, May 13, 2016 9:41:15 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,229
Hi,

Unfortunately no. As a browser engine, currently we do not have any way for you to circumvent this security restriction.

Thanks!
AiSatan
Posted: Saturday, May 14, 2016 10:54:26 AM
Rank: Advanced Member
Groups: Member

Joined: 2/11/2016
Posts: 35
Well, I can't using SendMouseEvent or something like that?
eo_support
Posted: Saturday, May 14, 2016 2:55:31 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,229
No. Browsing a file is not a simple mouse click. You might be able to use SendMouseEvent to bring up the file browsing dialog, but then you can't go further from there. So it would not work for you.

Thanks!
AiSatan
Posted: Saturday, May 14, 2016 3:20:13 PM
Rank: Advanced Member
Groups: Member

Joined: 2/11/2016
Posts: 35
I know, but not understand that you mean.
Can the SendMouseEvent click to the html input control?

If yes, I'll can use the event:

http://www.essentialobjects.com/doc/eo.webbrowser.webview.filedialog.aspx

and send my file as I do it now, but I must manually click on the html input.

And if yes, can you show an example with the Send Mouse Event?
on the site or any other sites where there is such the html input:

http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_fileupload_get
AiSatan
Posted: Saturday, May 14, 2016 4:30:31 PM
Rank: Advanced Member
Groups: Member

Joined: 2/11/2016
Posts: 35
So, I tried the mouseclick event, and it's work fine with FileDialog event. And now, I can upload file without user, thanks for help.

little example if someone else will need it

Code: C#
webControl1.WebView.FileDialog += (o, args) =>
			{
				args.Handled = true;
				args.Continue(@"C:\Users\AiSatan\Documents\testfile.red");
			};

			var scr = webControl1.WebView.QueueScriptCall("$('#inputSelector').offset().left");
			scr.WaitOne();
			var x = Convert.ToInt32(scr.Result);
			scr = webControl1.WebView.QueueScriptCall("$('#inputSelector').offset().top");
			scr.WaitOne();
			var y = Convert.ToInt32(scr.Result);
			webControl1.WebView.SendMouseEvent(MouseEventType.Click, new MouseEventArgs(MouseButtons.Left, 1, x, y, 0));
eo_support
Posted: Saturday, May 14, 2016 6:29:56 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,229
Glad to hear that you got it working. Thanks for sharing the code!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.