Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

HTML | DOM Input FileUpload value Property

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

The Input FileUpload value Property is used to returns the path or the name of the file selected with the element. This property is used to return the name of the selected file with a fake path in IE, Google Chrome, and Opera, and return the name of the selected file in Firefox and Safari. This property is read-only, because of security reasons. 

Syntax:

fileuploadObject.value

Example: Return the “path”

HTML




<!DOCTYPE html>
<html>
<head>
    <title>
        HTML DOM Input FileUpload value Property
    </title>
    <style>
        h1 {
            color: green;
        }
    </style>
</head>
<body>
    <center>
        <h1>
              Geeks for Geeks
          </h1>
        <input type="file"
               id="myFile"
               required>
        <p id="demo"></p>
        <button onclick="myFunction()">
            Click
        </button>
        <script>
            function myFunction() {
                var x =
                    document.getElementById(
                        "myFile").value;
 
                document.getElementById(
                    "demo").innerHTML = x;
            }
        </script>
    </center>
</body>
</html>

Output: 

Before Clicking the Button:

  

After Clicking the Button:

  

Supported Browsers:

  • Google Chrome 1+
  • Mozilla Firefox 1+
  • Edge 12+
  • Opera 11+
  • Apple Safari 1+

My Personal Notes arrow_drop_up
Last Updated : 29 Aug, 2022
Like Article
Save Article
Similar Reads
Related Tutorials