javascript - 使用 NeutralinoJS 获取输入文件路径
问题描述
如何使用 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}`)
}
推荐阅读
- angular - 将一个组件插入 CDK 门户
- java - java和kotlin之间的泛型!!帮我?
- javascript - 提取多个链接并使用 JQuery 在控制台中单击
- javascript - 当我在旧版本的写字板中打开文件时,某些字符会发生变化
- linux - 如何在centos linux上自动同步目录
- python - 如何使用 ODBC 链接 SQL 数据库并在 Python 中进行 SQL 查询
- c# - 为什么没有同时处理具有基本身份验证的 ASP.NET Web Api 请求?
- visual-studio - Visual Studio Extension 修改 Go to All 搜索结果?
- html - 背景中的图像始终位于同一位置?
- php - 以 Symfony 形式获取文件的数据