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

0 votes
Is it possible to determine if the user has selected a file for a particular input type="file" field using javascript/jQuery?
Jul 7 in Java-Script by kartik
• 20,980 points
36 views

1 answer to this question.

0 votes

Hello @kartik,

Yes ,you can read the value and even bind to the change event if you want.

<html>
<head>
  <title>Test 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>

But there are other, multiple-upload solutions that might suit your needs better, such as bpeterson76 posted.

Hope it helps!!

answered Jul 7 by Niroj
• 44,800 points

Related Questions In Java-Script

0 votes
1 answer

How to get the directory of the currently running file?

Hello @kartik, This should do it: import ( ...READ MORE

answered May 5 in Java-Script by Niroj
• 44,800 points
46 views
0 votes
1 answer

How to send data in request body with a GET when using jQuery $.ajax()?

Hello @kartik, Sending the data in your scenario,I ...READ MORE

answered Jun 18 in Java-Script by Niroj
• 44,800 points
483 views
0 votes
1 answer

How to access PHP session variables from jQuery function in a .js file?

Hello @kartik, You can produce the javascript file ...READ MORE

answered Jul 7 in Java-Script by Niroj
• 44,800 points
49 views
0 votes
1 answer

How to use Redirect in the new react-router-dom of Reactjs?

Hello, To navigate to another component you can ...READ MORE

answered May 18 in Java-Script by Niroj
• 44,800 points
611 views
0 votes
1 answer

How can we Create Multiple Where Clause Query Using Laravel Eloquent?

Hii, You can use Conditions using Array: $users = User::where([ ...READ MORE

answered Mar 30 in Laravel by Niroj
• 44,800 points
1,235 views
0 votes
1 answer

How to send email using php?

Hello @kartik 1.) Download PHPMailer, open the zip file ...READ MORE

answered Apr 1 in PHP by Niroj
• 44,800 points
54 views
0 votes
1 answer

Where to register Facades & Service Providers in Lumen?

Hello, To register a facade with an alias, ...READ MORE

answered Apr 6 in Laravel by Niroj
• 44,800 points
248 views
0 votes
1 answer

How can I update NodeJS and NPM to the next versions?

Hello @kartik, First check your NPM version npm -v 1).Update ...READ MORE

answered May 5 in Java-Script by Niroj
• 44,800 points
48 views
0 votes
1 answer
0 votes
1 answer

How to access PHP session variables from jQuery function in a .js file?

Hello, You can produce the javascript file via ...READ MORE

answered Apr 29 in Java-Script by Niroj
• 44,800 points
1,070 views