1

I am going to write simple frontend for my console tool. Generally, it takes a few parameters and input file path for further opening and processing. My idea was to place something like

 UI.input # set (attr "type") "file" # set UI.text "input filename"

And then get the selected file path via 'value'. But it appears that due to security reasons browsers do not provide full path to selected file.
Is it possible to place any file chooser with threepenny-gui?

Triostrong
  • 107
  • 8
  • 1
    I'm not aware of any browser feature that exposes the full file path. I think even the `FileList`/`FileReader` API abstracts that away. My thought would be to implement a file chooser UI, interacting with the directory structure from the server since it's local (I believe?) and navigating the tree in the browser. – ryachza Oct 19 '17 at 20:04

1 Answers1

1

As far as I know, web browsers do not allow you to obtain a filepath via the fields, for reasons of security. You can only obtain the file contents. Of course, you can always ask for a filepath in a plaintext input field, but that is certainly less convenient for the user.

Filepaths can be obtained from a file chooser dialog if you combine Threepenny with the Electron framework. Working with files is one of the reasons for using Electron.

Heinrich Apfelmus
  • 11,034
  • 1
  • 39
  • 67