Find out which type of form element the file upload button is:
var x = document.getElementById("myFile").type;
Click button below to find out which type of form element the FileUpload object is.
<!DOCTYPE html> <html> <body> Select a file to upload: <input type="file" id="myFile"> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {//from ww w . j a v a2 s. com var x = document.getElementById("myFile").type; document.getElementById("demo").innerHTML = x; } </script> </body> </html>
The type property returns which type of form element the file upload button is.
For a file upload button, this property will always return "file".