Upload file without OpenFileDialog shown

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

Upload file without OpenFileDialog shown

Postby UKS » Sat Aug 04, 2018 7:27 pm

I have found that this was possible up from 2014: https://github.com/cefsharp/CefSharp/pu ... 29e61bab79

but in the same time... looks like this feature was deleted, as sample of code:
Code: Select all
using System.Collections.Generic;
using System.IO;
namespace CefSharp.Example
{
    public class TempFileDialogHandler : IDialogHandler
    {
        public bool OnFileDialog(IWebBrowser browser, string title, string defaultFileName, List<string> acceptTypes, out List<string> result)
        {
            result = new List<string> { Path.GetRandomFileName() };
            return true;
        }
    }
}


doesn't work anymore... =(

How can I Upload file without shown OpenFileDialog?
UKS
Newbie
 
Posts: 3
Joined: Sat Jun 30, 2018 6:20 am

Re: Upload file without OpenFileDialog shown

Postby UKS » Mon Aug 06, 2018 1:53 pm

Code: Select all
   public class TempFileDialogHandler : IDialogHandler
   {
      string[] _filePath;

      public TempFileDialogHandler(params string[] filePath)
      {
         _filePath = filePath;
      }

      public bool OnFileDialog(IWebBrowser browserControl, IBrowser browser, CefFileDialogMode mode, string title, string defaultFilePath, List<string> acceptFilters, int selectedAcceptFilter, IFileDialogCallback callback)
      {
         callback.Continue(0, _filePath.ToList());
         return true;
      }
   }



And usage:

Code: Select all
    Browser.DialogHandler = new TempFileDialogHandler(files);
UKS
Newbie
 
Posts: 3
Joined: Sat Jun 30, 2018 6:20 am

Re: Upload file without OpenFileDialog shown

Postby HarmlessDave » Mon Aug 06, 2018 2:11 pm

Do you mean Download a file without showing a Save As dialog?

For uploading, can't you just build your own CefRequest with Post data?
HarmlessDave
Expert
 
Posts: 370
Joined: Fri Jul 11, 2014 2:02 pm


Return to Support Forum

Who is online

Users browsing this forum: Google [Bot] and 39 guests