How to fire event on file select in jQuery

Topic: JavaScript / jQuery« Prev|Next »

Answer: Use the jQuery change() method

You can use the jQuery change() method to fire an event to do something when the user select any file using the file <input> type box.

  • <!DOCTYPE html>
  • <html lang="en">
  • <head>
  • <meta charset="UTF-8">
  • <title>jQuery Fire Event on File Select</title>
  • <script src=""></script>
  • <script type="text/javascript">
  •     $(document).ready(function(){
  •         $('input[type="file"]').change(function(){
  •             alert("A file has been selected.");
  •         });
  •     });
  • </script>
  • </head>
  • <body>
  •     <form>
  •         <input type="file">
  •     </form>
  • </body>
  • </html>

Related FAQ

Here are some more FAQ related to this topic:


Your Feedback:


We would love to hear from you! Please say something.