Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

298
Visualizações
Chrome extension close causes file not being upload

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.

    • Note: I don't know why this method of debuging the extension is not the first thing mentioned in the Getting Started guide.
  • 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:

popup.html
<div id="footer" class="popup_footer">
  <label for="upload" class="badge upload"> &#11014; </label>
  <input type="file" id="upload" href="#" title="&#128190;" />
</div>
popup.js
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:

  1. Upload it in the chrome-extension url mentioned before.
  2. Using an auxiliary options.html page

There is a way to achieve this without a workaround? Thanks in advance

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda