Skip to content

Commit 7e83236

Browse files
author
郑小波
committed
fix(Upload): bugs of IE
1 parent ccce4b3 commit 7e83236

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/upload/runtime/request.jsx

+5-3
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ export default function upload(option) {
7373
option.onSuccess(getBody(xhr), xhr);
7474
};
7575

76+
option.method = option.method || 'POST';
77+
xhr.open(option.method, option.action, true);
78+
79+
// In Internet Explorer, the timeout property may be set only after calling the open() method and before calling the send() method.
80+
// see https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/timeout
7681
const { timeout } = option;
7782

7883
if (typeof timeout === 'number' && timeout > 0) {
@@ -83,9 +88,6 @@ export default function upload(option) {
8388
};
8489
}
8590

86-
option.method = option.method || 'POST';
87-
xhr.open(option.method, option.action, true);
88-
8991
// Has to be after `.open()`. See https://github.com/enyo/dropzone/issues/179
9092
if (option.withCredentials && 'withCredentials' in xhr) {
9193
xhr.withCredentials = true;

src/upload/runtime/selecter.jsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,9 @@ export default class Selecter extends React.Component {
8181
if (!el) {
8282
return;
8383
}
84-
el.click();
84+
// NOTE: 在 IE 下,el.value = '' 在 el.click() 之后,会触发 input[type=file] 两次 onChange
8585
el.value = '';
86+
el.click();
8687
};
8788

8889
/**

0 commit comments

Comments
 (0)