change()
methodYou 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">
<head>
<meta charset="utf-8">
<title>jQuery Get Selected File Name</title>
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script>
$(document).ready(function(){
$('input[type="file"]').change(function(e){
var fileName = e.target.files[0].name;
alert('The file "' + fileName + '" has been selected.');
});
});
</script>
</head>
<body>
<form>
<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>
</form>
</body>
</html>
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 [email protected]
How To Create ZIP File In Laravel Using ZipArchive
Hello, Everyone in this tutorials we are...How to sort an associative array by key in PHP
Use the PHP ksort() and k...How to get Current User Location in Laravel 7
In this tutorial, i am going to show you...Create and Setup Symfony Project
Symfony is fast and leading PHP framewor...Google pie chart with ajax request example in PHP
In this tutorial, we will go through imp...