Reputation: 3283
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?
Upvotes: 4
Views: 8270
Reputation: 73966
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());
});
Upvotes: 4
Reputation: 35223
If you just need the filename:
$('#my_file').change(function(){
var filename = $(this).val().split('\\').pop();
});
Upvotes: 5