|
824 | 824 | if (elFailedMessage) {
|
825 | 825 | elFailedMessage.textContent = " - " + e.type;
|
826 | 826 | }
|
| 827 | + batches.length = 0; |
827 | 828 | }
|
828 | 829 |
|
829 | 830 | function onLoad() {
|
830 |
| - !uploading && location.reload(); |
| 831 | + var status = this.status; |
| 832 | + if (status >= 200 && status <= 299) { |
| 833 | + !uploading && location.reload(); |
| 834 | + } else { |
| 835 | + onFail({type: this.statusText || this.status}); |
| 836 | + } |
831 | 837 | }
|
832 | 838 |
|
833 | 839 | function onProgress(e) {
|
|
846 | 852 | batches.push(files);
|
847 | 853 | } else {
|
848 | 854 | uploading = true;
|
| 855 | + removeClass(elUploadStatus, classFailed); |
849 | 856 | addClass(elUploadStatus, classUploading);
|
850 | 857 | uploadBatch(files);
|
851 | 858 | }
|
|
871 | 878 | });
|
872 | 879 |
|
873 | 880 | var xhr = new XMLHttpRequest();
|
874 |
| - xhr.upload.addEventListener('error', onComplete); |
875 |
| - xhr.upload.addEventListener('error', onFail); |
876 |
| - xhr.upload.addEventListener('abort', onComplete); |
877 |
| - xhr.upload.addEventListener('abort', onFail); |
878 |
| - xhr.upload.addEventListener('load', onComplete); |
879 |
| - xhr.upload.addEventListener('load', onSuccess); |
880 |
| - xhr.upload.addEventListener('load', onLoad); |
| 881 | + xhr.addEventListener('error', onComplete); |
| 882 | + xhr.addEventListener('error', onFail); |
| 883 | + xhr.addEventListener('abort', onComplete); |
| 884 | + xhr.addEventListener('abort', onFail); |
| 885 | + xhr.addEventListener('load', onComplete); |
| 886 | + xhr.addEventListener('load', onSuccess); |
| 887 | + xhr.addEventListener('load', onLoad); |
881 | 888 | if (elProgress) {
|
882 | 889 | xhr.upload.addEventListener('progress', onProgress);
|
883 | 890 | }
|
|
0 commit comments