I'm devoloping a chrome extension that uses an <input type="file"> inside the popup.html.
The problem is:
When is tested inside chrome-extension://ID_EXTENSION/popup.htmlit works as inteded.
When is tested in normal envoriment (clicking the extension) the file is not upload correctly. Maybe is because, when the file selector dialog is opened, the chrome extensions closes.
Sample code of how this is implimented:
<div id="footer" class="popup_footer">
<label for="upload" class="badge upload"> ⬆ </label>
<input type="file" id="upload" href="#" title="💾" />
</div>
document
.getElementById("upload")
.addEventListener("change", function(e) {
var file = e.target.files[0];
var reader = new FileReader();
reader.onload = function(e) {
var data = JSON.parse(e.target.result);
chrome.storage.sync.set({data: data})
};
reader.readAsText(file)
As a workaround I tested:
chrome-extension url mentioned before.options.html pageThere is a way to achieve this without a workaround? Thanks in advance