This is the uploaded form.
<form class="alert alert-info">
<div>
<b id = "select_file" class="span3" style="font-weight: bold; cursor: pointer; ">Please select image</b>
<input class="span3" type="file" name="image_file" id="image_file" style="display:none " />
<input disabled="true" type="button" value="Upload image" class="btn" />
</div>
</form>
I use the following script to open a window with files. I want to show a file name in <b id = 'select_file'>
.
How can I do this?
$('#select_file').click(function(){
var _this = $(this);
$('#image_file').show().focus().click().hide();
var filename = $('#image_file').val();
_this.html(filename);
$('.btn').attr('disabled', false);
});
You can access to the properties you want passing an argument to your callback function (like
evt
), and then accessing the files with it (evt.target.files[0].name
) :You have to do this on the change event of the
input type file
this way:If selected more 1 file:
files
will be aFileList
object.names
is an array of strings (file names).Using Bootstrap
Remove form-control-file Class from input field to avoid unwanted horizontal scroll bar
Try this!!