|
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.
|
|
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!
|
|
Rank: Advanced Member Groups: Member
Joined: 2/11/2016 Posts: 35
|
Well, I can't using SendMouseEvent or something like that?
|
|
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!
|
|
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.aspxand 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
|
|
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));
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Glad to hear that you got it working. Thanks for sharing the code!
|
|