Change the name of a file upload button:
document.getElementById("myFile").name = "newFileName";
Click the buttons below to display or change the value of the name attribute of the file button.
<!DOCTYPE html> <html> <body> A FileUpload object: <input type="file" id="myFile" name="filename"> <p id="demo"></p> <button onclick="display()">Display name</button> <button onclick="change()">Change name</button> <script> function display() { var x = document.getElementById("myFile").name; document.getElementById("demo").innerHTML = "The name of the file button is: " + x; } function change() {/*from ww w.j a va 2 s . co m*/ var x = document.getElementById("myFile").name = "newFileName"; document.getElementById("demo").innerHTML = "The name was changed to: " + x; } </script> </body> </html>