We are using CefSharp (v37.0.0 NuGet package) in a C# WinForms application. We are looking for a way to (programmatically) trigger file upload actions. How, if at all, can that be done?
A couple of additional thoughts:
- We have a file upload dialog on a page where, normally, a user would select a file. This works fine, we intercept the dialog call via IDialogHandler and provide the file.
- Now we want to trigger the same dialog and pre-set the file. While the dialog opens successfully from an "ExecuteScriptAsync" call, we are unable to pre-select the file. Possibly due to the following reason: how to create/initialize the file object using file path html5
- Our next idea was to have the dialog open normally and issue a click event programmatically so the browser would open the file dialog (which we would then catch via IDialogHandler and provide the file we desire).
- Trying this approach, our observation is as follows:
- Following a user action (e.g. button click inside the browser), we can programmatically "click" the file input button.
- Doing the same from a call originating via ExecuteScriptAsync, the dialog (or call in IDialogHandler) does not come up.