Skip to content

Commit

Permalink
Merge 9f014fc into 48928fb
Browse files Browse the repository at this point in the history
  • Loading branch information
whatwewant committed May 27, 2020
2 parents 48928fb + 9f014fc commit cf8e8df
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions components/upload/PropsType.tsx
Expand Up @@ -26,6 +26,7 @@ export default interface PropsType {
fileExt?: string;
className?: string;
style?: object;
headers?: Record<string, string>;
onSelect: (files: any) => boolean;
onProgress: () => void;
onComplete: (file: any, res?) => void;
Expand Down
8 changes: 7 additions & 1 deletion components/upload/Upload.tsx
Expand Up @@ -9,6 +9,7 @@ class Upload extends Component<PropsType, any> {
startUpload: false,
autoUpload: true,
isRadius: false,
headers: {},
data: {},
url: '',
onSelect: () => {},
Expand Down Expand Up @@ -79,7 +80,7 @@ class Upload extends Component<PropsType, any> {
// 上传附件
onUpload(file) {
const {
url, fileName, data, onComplete, onError,
url, fileName, headers, data, onComplete, onError,
} = this.props;
const URL = /^(http:\/\/|https:\/\/|\/\/)/;
const { origin } = window.location;
Expand Down Expand Up @@ -131,6 +132,11 @@ class Upload extends Component<PropsType, any> {
// };

xhr.open('post', url);

for (const key in headers) {
xhr.setRequestHeader(key, headers[key]);
}

xhr.send(fd);
return true;
}
Expand Down

0 comments on commit cf8e8df

Please sign in to comment.