HTML | DOM Input FileUpload disabled Property

The Input FileUpload disabled property in HTML DOM used to set or return whether a file upload field must be disabled, or not.
A disabled field is unusable and un-clickable. It is a boolean attribute and used to reflect the HTML Disabled attribute. It is usually rendered in grey color by default in all the Browsers.

Syntax:

  • Return the disabled property:
    fileuploadObject.disabled
  • Set the disabled property:
    fileuploadObject.disabled=true|false

Property Values:



  • true: It defines that the FileUpload field is disabled
  • false: It has a default value. It defines that the FileUpload field is not disabled

Return Value: It returns a boolean value which represents that the Input FileUpload field is disabled or not.

Example-1: Return FileUpload property

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Output:
Before Click:

After Click:

Example-2: Set the FileUpload property

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Output:
Before Click:

After Click:

Supported Browsers:

  • Google Firefox
  • Mozilla Firefox
  • Edge
  • Opera
  • Safari


My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



Improved By : shubham_singh



Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.