So, let's say you have some kind of html form, and you have user input to upload files:
<label for="imageUploadButton"> <span class="btn" style="padding-left: 10px;">Click here for uploading a new picture</span> </label> <input type="file" name="avatar_picture" accept="image/gif,image/jpeg,image/png" id="imageUploadButton" style="visibility: hidden; position: absolute;">
And you want to check the name of the file that the user has selected / selected:
Using jquery
<script type="text/javascript"> $(function() { $("input:file").change(function (){ var fileName = $(this).val(); alert(fileName); </script>
@ fooobar.com/questions/38646 / ...
For those using requireJS:
$("input:file").change(function () { var fileName = $(this).val(); alert(fileName);
Combine
source share