How to add a button to select a file without uploading but storing the full filename

In my database the user needs to link files to entities. So he must select a file and this filename has to be stored to the entity. No upload, just the full filename with path and drive.

The fileUploadField does not give me the full filename ;/

Anybody any ideas ?

Hello,

https://docs.jmix.io/jmix/flow-ui/vc/components/fileStorageUploadField.html

It will store a reference to the FileStorage as FileRef in your entity.
From there, one can have fileRef.getFileName and fileRef.getPath and from that you can construct a path string, and then maybe store it into separate field or calculate on the fly.

Kind regards,
Mladen

Ah sorry, must select the file, not upload it.
I would then look into extending the Upload, and modifying it so it doesn’t upload.

Hi Mladen

Thank you, I was there :wink:

The problem is, that there is always the temporaryStorage involved and I do not get the absolute path of the selected file.

Kind regards
Felix

Hi,

Could you please describe your task in more detail? Do users select files from their PC and need to store the file path related to that PC, or do they select files that have already been uploaded and want to link them to an existing file rather than making a copy?

Regards,
Gleb

Hi Gleb

There is a big network drive with a lot of pictures which people need to link to the appropriate entity. So no upload or download :wink:

Regards
Felix

AFAIK, file input element doesn’t provide file path related to user PC for security reasons. It seems that your task requires implementing custom file selector components, e.g. using The File System Access API