如何使用 NeutralinoJS 获取输入文件路径?
我的代码:
<input type="file" id="inputFile">
const inputFilePath = document.getElementById('inputFile').files[0].path
console.log(inputFilePath)
最佳答案
我认为浏览器不允许您获取文件路径。
您可以使用文件选择器 API os.showDialogOpen(DialogOpenOptions)
:
https://neutralino.js.org/docs/api/os#osshowdialogopendialogopenoptions
<button onclick="onFileUpload()">
async onFileUpload () {
let response = await Neutralino.os.showDialogOpen({
title: 'Select a file'
})
console.log(`You've selected: ${response.selectedEntry}`)
}
关于javascript - 使用 NeutralinoJS 获取输入文件路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67775464/