How to use WebOpenDialog

Hi.

Do you have an example with WebOpenDialog? The workflow is not similar to the traditional OpenDialog.
1- The "Execute" does not return a bool value. How do we know if a file is selected or the users selected "Cancel?
2- The "Filename" attribute shows only file name and not the path to the file. I cannot find the path in any other attribute.
3- The selected filename is not available until the next execute call. After the first exec the filename is empty. Next time it has the previous file name.

Can you provide a working example?

BR
Amin

Please have a look at the upload example. It is available in Basics/Upload. Remember that there is no traditionalopen file dialog in web application. Web applications cannot access local resources. Only the web browser can upload local resources and that whole functionality depends on your browser and not the web application.

There is a separate component for use in Electron applications which allow access to local resources.

Hi
I am confused. The following is from the Web Core documentation:

The TWebOpenDialog non-visual component allows to start a dialog to pick files from the local file system.

I want to do exactly that. Do you mean that I cannot do that? I cannot even get the file name. Is there any example with WebOpenDialog?

The "Upload" example is using a WebFilepicker. Not exactly the workflow I am looking for.

Can I put an ElectronOpenDialog and use it on Web application project? I get the following error If I do run the application:

ERROR
Uncaught TypeError: Cannot read property 'ipcRenderer' of null | TypeError: Cannot read property 'ipcRenderer' of null at Object.InitPaths (http://localhost:8000/Tina_FNC/Tina_FNC.js:142121:35) at Object.ElectronPath (http://localhost:8000/Tina_FNC/Tina_FNC.js:142626:19) at Object.$mod.$init (http://localhost:8000/Tina_FNC/Tina_FNC.js:142689:10) at loadimpl (http://localhost:8000/Tina_FNC/Tina_FNC.js:213:46) at Object.loaduseslist (http://localhost:8000/Tina_FNC/Tina_FNC.js:189:7) at loadimpl (http://localhost:8000/Tina_FNC/Tina_FNC.js:201:9) at Object.loaduseslist (http://localhost:8000/Tina_FNC/Tina_FNC.js:189:7) at loadimpl (http://localhost:8000/Tina_FNC/Tina_FNC.js:201:9) at Object.loaduseslist (http://localhost:8000/Tina_FNC/Tina_FNC.js:189:7) at Object.loadimpl (http://localhost:8000/Tina_FNC/Tina_FNC.js:201:9)
at http://localhost:8000/Tina_FNC/Tina_FNC.js [142121:35]

BR
Amin

Sorry for causing confusion. That was not my intent.

First, no, you cannot use Electron components in a ‘normal’ web application. Electron applications are special.

The file picker also allows you to select files and get the list of files the user selected. There is no need for an upload.

However, I will look at TWebOpenDialog asap and will give you an answer asap. I apologize, but TMS WEB Core is offering so much that I mixed things up. My mistake, I will look into it.

Place a TWebButton and TWebOpenDialog on the form. Also, drop a TWebMemo.

image

The call to Execute is non-blocking. That means, the event OnChange has to be used to determine when the dialog has been closed and files have been selected. If the user clicks cancel, no files are added to the Files property of the dialog and the event is not triggered.

Here's a possible implementation to list all selected files in the memo control.

procedure TForm1.DialogChange(Sender: TObject);
var
 i : Integer;

begin
  for i := 0 to  Dialog.Files.Count - 1 do
  begin
    WebMemo1.Lines.Add( Dialog.Files[i].Name) ;
  end;
end;

procedure TForm1.WebButton1Click(Sender: TObject);
begin
  Dialog.Execute;
end;