我将开发一个 Chrome 扩展程序,当文件开始从 Chrome 浏览器下载并出于某些目的读取文件时检测状态。
let downloadIds = [];
chrome.downloads.onCreated.addListener(function (downloadItem) {
console.log("filename with absolute local path " , downloadItem.filename); // prints ""
// Just FYI, you won't get downloadItem.filename here. So store the downloadId
downloadIds.push(downloadItem.id);
});
chrome.downloads.search({id: downloadIds[0]}, function (downloadItem) {
console.log("filename with absolute local path " , downloadItem.filename);
// prints "C:/user/downloads/yourfile"
});
现在在您的
<input type="file" >
中使用 popup.html
并访问与步骤中获取的文件名匹配的文件