CEF3 upload file without open dialog

940 Views Asked by At

I'm use CEF 3.2454.1344.g2782fb8 (Chromium 45.0.2454.101) in my project in Delphi 10.1. (I have to use a fairly old version of CEF/Chromium for backwards compatibility with WinXP). So my question is: when I click "Upload" button on any site I get a open file dialog, and have to choose a file to upload. It is possible to do not show this dialog to user, but give CEF some pre-assigned file instead?

UPDATE: I've tried to do this via OnFileDialog, it's exactly I need: after clicking on "Upload" button I got a file shown on a web page, but Chromium instantly crashed after this. Any ideas?

procedure TMainForm.crm_asFileDialog(Sender: TObject;
  const browser: ICefBrowser; mode: TCefFileDialogMode;
  const title, defaultFilePath: ustring; acceptFilters: TStrings;
  selectedAcceptFilter: integer; const callback: ICefFileDialogCallback;
  out Result: Boolean);
var
  file_list: tstringlist;
begin
  file_list := tstringlist.Create;
  file_list.Add
    ('https://testsite.com/my_image.jpg');
  callback.Cont(0, file_list);
  file_list.Free;
  Result := true;
end;

UPDATE 2: HTML code of a form

<form method="post" enctype="multipart/form-data">
  <input accept="image/*" type="file" name="file1" />
  <input accept="image/*" type="file" name="file2" />
  <input accept="image/*" type="file" name="file3" />
</form>
0

There are 0 best solutions below