Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

196
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda