How to get “value” of file upload input field in jquery?

Web Development

Is it possible to determine if the user has selected a file for a particular input type="file" field using javascript/jQuery?


If you want to unleash your potential in this competitive field, please visit the Web Development course page for more information, where you can find the Web Development tutorials and Web Development frequently asked interview questions and answers as well.

1
Answers

Replies

Ans: Yes, the value can be read and bind to the change event if you wish.


<html>


<head>


  <title>Demo Page</title>


  <script src="code.jquery.com/jquery-latest.js"></script>


  <script type="text/javascript">


  $(function()


  {


    $('#tester').change( function()


    {


      console.log( $(this).val() );


    });


  });


  </script>


</head>


<body>


<input type="file" id="tester" />


</body>


</html>

 
 

This topic has been locked/unapproved. No replies allowed

Login to participate in this discussion.

Leave a reply

Before proceeding, please check your email for a verification link. If you did not receive the email, click here to request another.
WhatsApp
To Top