I am using trigger('click') while using the file upload in jQuery. I am providing my code below.
$(document).on('click', '.browse', function(){
var file = $(this).parent().parent().parent().find('.file');
file.trigger('click');
console.log('header');
})
My html part is given below.
<div class="form-group" style="margin-bottom:0px;">
<input type="file" name="logoimage" id="logoimage" ng-model= "form.logoimage" onchange="angular.element(this).scope().uploadedImage(this);" accept=".gif,.jpg,.jpeg,.png" class="file">
<div class="input-group col-xs-12">
<input type="text" class="form-control" placeholder="Upload Logo" name="setlogoimage" id="setlogoimage" ng-model="setlogoimage">
<span class="input-group-btn">
<button class="browse btn btn-primary" type="button">Upload File</button></span>
</div>
</div>
If I am clicking on file input the above function is executing 3/2 times and I can know it from the console messages. At one time click header is coming 3 times as result I have to click on open button after selecting file from discs also 3 times. Here I need to execute at once at one time click.
input type=filein a single page whose class name is.filebut its working sometimes and max times this scenarioa.Uncaught TypeError: Cannot read property 'length' of undefined.