Reputation: 23483
FileReader
onload
not getting fired on second time when the same file selected with Chrome, it's getting fired all the time for FireFox.
function uploadCover(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function(e) {
var image = new Image();
image.src = e.target.result;
image.onload = function () {
// code
};
};
reader.readAsDataURL(input.files[0]);
}
}
Here I want to validate image width and height on upload. So there is two scenarios which is ending up with issue:
User selects same image without any change.
This time user should get validation message again.
User edited the image and changed size, uploaded again.
Again file value not changed, so the upload or validation not getting called.
Upvotes: 5
Views: 6410
Reputation: 336
Check this questions that are similar to your problem:
Chrome file upload bug: on change event won't be executed twice with the same file
input file onchange event not being fired in chrome
Upvotes: 1