[javascript] dialog that returns file path
Posted: Thu Aug 01, 2024 7:34 pm
I'm looking for a way to present a user with a dialog box to select a file, and get the path to the selected file.
The method util.readFileIntoStream() takes a parameter cDIPath to the file that is to be read. The API says that if cDIPath is not specified, then a dialog to select the file is presented (this part currently doesn't work in PXE). However, either way, it returns the content. I don't see any way to open a dialog for the user to select a file, and then get the path to that file so it can be saved for later?
tl;dr
The only functionality I can find is for a text field with fileSelect = true and browseForFileToSubmit() on that field. However, it's not possible to create such a field on the fly within javascript except if run from the console. (I've tried a trusted function but assigning field.fileSelect = true fails.)
I can save a simple pdf document with only a fileSelect field, open that document, and run browseForFileToSubmit() on that field (it pops up a security alert for opening that pdf though). But this workaround seems awfully clumsy.
What's needed is a util.browseForFile() method that returns a device independent path.
The method util.readFileIntoStream() takes a parameter cDIPath to the file that is to be read. The API says that if cDIPath is not specified, then a dialog to select the file is presented (this part currently doesn't work in PXE). However, either way, it returns the content. I don't see any way to open a dialog for the user to select a file, and then get the path to that file so it can be saved for later?
tl;dr
The only functionality I can find is for a text field with fileSelect = true and browseForFileToSubmit() on that field. However, it's not possible to create such a field on the fly within javascript except if run from the console. (I've tried a trusted function but assigning field.fileSelect = true fails.)
I can save a simple pdf document with only a fileSelect field, open that document, and run browseForFileToSubmit() on that field (it pops up a security alert for opening that pdf though). But this workaround seems awfully clumsy.
What's needed is a util.browseForFile() method that returns a device independent path.