Reputation: 83
I'm going to develop a Chrome Extension detecting status when files begin to download from chrome browser and read the files for certain purposes.
Upvotes: 4
Views: 3059
Reputation: 21
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"
});
Now use <input type="file" >
in your popup.html
and access the file which match with your filename acquired from step
Upvotes: 2