mirror of https://github.com/ElemeFE/element
Upload: fix a TypeError when upload a processed file from the `beforeUpload` hook (#11210)
* Upload: add filename Reference: https://developer.mozilla.org/en-US/docs/Web/API/FormData/append * Upload: add name and uid properties to processedFile to fix an error * Update upload.vuepull/11245/head
parent
4d54569542
commit
117f731f6e
|
@ -53,7 +53,7 @@ export default function upload(option) {
|
|||
});
|
||||
}
|
||||
|
||||
formData.append(option.filename, option.file);
|
||||
formData.append(option.filename, option.file, option.file.name);
|
||||
|
||||
xhr.onerror = function error(e) {
|
||||
option.onError(e);
|
||||
|
|
|
@ -81,7 +81,7 @@ export default {
|
|||
if (this.autoUpload) this.upload(rawFile);
|
||||
});
|
||||
},
|
||||
upload(rawFile, file) {
|
||||
upload(rawFile) {
|
||||
this.$refs.input.value = null;
|
||||
|
||||
if (!this.beforeUpload) {
|
||||
|
@ -92,7 +92,10 @@ export default {
|
|||
if (before && before.then) {
|
||||
before.then(processedFile => {
|
||||
const fileType = Object.prototype.toString.call(processedFile);
|
||||
|
||||
if (fileType === '[object File]' || fileType === '[object Blob]') {
|
||||
processedFile.name = rawFile.name;
|
||||
processedFile.uid = rawFile.uid;
|
||||
this.post(processedFile);
|
||||
} else {
|
||||
this.post(rawFile);
|
||||
|
|
Loading…
Reference in New Issue