Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

184
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!