![](/img/trans.png)
[英]FileReader onload not getting fired for second attempt in IE 11 after contents of the uploaded file is changed
[英]FileReader onload not getting fired when selecting same file in Chrome
當用Chrome選擇同一個文件時, FileReader
onload
第二次沒有被觸發,它一直被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]);
}
}
在這里,我想驗證上傳時的圖像寬度和高度。 因此有兩種情況最終會出現問題:
用戶選擇相同的圖像沒有任何變化。
這次用戶應該再次獲得驗證消息。
用戶編輯了圖像並更改了尺寸,再次上傳。
文件值再次沒有改變,因此上傳或驗證沒有被調用。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.