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

195
Visualizações
How to modify the file name of <input type="file"/> with jquery?

I use this code to modify input type="file" file name.

html:

<input type="file" id="videoUpload"/>

js:

var fileName = $("#videoUpload").prop("files")[0].name;

console.log(a) //testA.mp4

$("#videoUpload").prop(("files")[0].name,"myVideo.mp4")
console.log(a) //testA.mp4

The file name is not changed,why?

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

0

What you could do is before the form is submitted, copy the file, rename it and replace it. (assuming your input has name=inputName)

yourFormElement.addEventListener("formdata", ({formData}) => {
  const file = formData.inputName.files[0];
  const blob = new Blob([file],{type: file.type});
  const file2 = new File([blob], "foo.bar", {type: blob.type});
  formData.set("inputName", [file2]);
});

But as Quentin said, this is something that you usually have to do on the server because anyone can open the devtools do the changes from above and override other users files on the server.

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