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

206
Visualizações
Input file element's docx file's content type is not correct?

I know that the docx's MIME type is

application/vnd.openxmlformats-officedocument.wordprocessingml.document

But whenever I pick an docx file using <input type="file">, the type is empty ?

<!DOCTYPE html>

<html>
<body>

  <input type="file" id="myfile" name="myfile" multiple><br><br>
  <button onclick="logFile(event)">CLick</button>

</body>

<script>
function logFile(e) {
    var myFile = document.getElementById("myfile");
    console.table(myFile.files[0])
}
</script>
</html>

This code will log a table with type = application/pdf when you pick an pdf, but when you pick a docx file type = ""

Because of the type is empty, when I send it to my server, the browser auto read the docx files as application/octet-stream, which is not what I want

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

MIME types are not really a browser/client thing. Especially Windows knows nothing about them and uses the file extension instead, and neither it nor browsers have have a list or mapping of file extensions to MIME types.

Additionally, even if the browser would send a MIME type, you NEVER can trust anything that a client sends to you. You will in any case need to look at the content of sent file and check if it actually is the file type you expect.

about 4 years ago · Juan Pablo Isaza Relatório
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