I want to show the file name while uploading the file.For that i used the hidden field. My code is
<label>File</lable>
<input type="image" src="http://upload.wikimedia.org/wikipedia/commons/c/ca/Button-Lightblue.svg" width="30px"/>
<input type="file" id="my_file" style="display: none;" />
javascript is
$("input[type='image']").click(function() {
$("input[id='my_file']").click();
});
How can I do this?
If you just need the filename:
$('#my_file').change(function(){
var filename = $(this).val().split('\\').pop();
});
You can do this:
$("input[type='image']").click(function () {
$("input[id='my_file']").click();
});
$("input[id='my_file']").change(function (e) {
var $this = $(this);
$this.next().html($this.val().split('\\').pop());
});
FIDDLE
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With