How to get selected file name from input type file using jQuery

  1888 views   11 months ago jQuery

Use the jQuery change() method

You can use the jQuery change() method to get the file name selected by the HTML form control <input type="file">. Let's check out an example to understand how it works:

<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8">
<title>jQuery Get Selected File Name</title>
<script src=""></script>
            var fileName =[0].name;
            alert('The file "' + fileName +  '" has been selected.');
        <input type="file">
        <p><strong>Note:</strong> Choose any file on your computer and its name will be displayed in an alert dialog box.</p>


Author : Harsukh Makwana
Harsukh Makwana

Hi, My name is Harsukh Makwana. i have been work with many programming language like php, python, javascript, node, react, anguler, etc.. since last 5 year. if you have any issue or want me hire then contact me on

Related Articles