New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can dialog#showOpenDialog return File instances instead of paths? #6809
Comments
No, |
@zcbenz I understand the differences. However, now the deveopers have to deal with different file input from user in renderer and in menu. Right now, the only way to upload or read a file from I think this is totally valid scenario to consider. What do you think? |
Can you share your hack here? |
@zeke So I have hidden file input in renderer, I send ipc message from Main after user clicks on a menu item, the message is listened to in renderer and when it arrives I call This is on the page: <input type="file" id="file__hidden" style="visibility: hidden" multiple /> This in the main process: const template = [
{
label: 'File',
submenu: [
{
label: 'Open Files',
click() {
mainWindow.webContents.send('hidden-file-input-open')
}
}
]
}
]
Menu.setApplicationMenu(Menu.buildFromTemplate(template)) And this in the renderer: ipcRenderer.on('hidden-file-input-open', (e, args) => {
document.getElementById("file__hidden").click() // this does not work
// this does work
const code = 'document.getElementById("file__hidden").click()'
electron.webFrame.executeJavaScript(code, true)
}) The I've cloned We're talking about this issue in electron Slack channel, please join if you have anything to say. |
I just found out that this issue is related to #749. |
Currently, when choosing files from filesystem using dialog#showOpenDialog, it "returns an array of file paths chosen by the user". That's strings.
However, when using a
<input type="file"..
form or a drag&drop for taking files into a browser, these return instances of File.Would it make sense / would it be possible to return
File
s from Electron'sshowOpenDialog
?The text was updated successfully, but these errors were encountered: