upload image fix

This commit is contained in:
JimQing 2020-05-02 16:28:00 +08:00
parent 0abb90cb4f
commit 779760b281
2 changed files with 13 additions and 3 deletions

View File

@ -131,7 +131,7 @@ export default {
data.append('file', pasteFile) data.append('file', pasteFile)
fileApi.fileUpload(data).then(res => { fileApi.fileUpload(data).then(res => {
this.uploaded(res.data) this.uploaded(res)
}).catch(err => { }).catch(err => {
console.log(err.message) console.log(err.message)
}) })

View File

@ -1,7 +1,8 @@
<template> <template>
<el-container class="top"> <el-container class="top">
<!-- 图片上传 --> <!-- 图片上传 -->
<el-upload class="header__item" action="https://imgkr.com/api/files/upload" :headers="{'Content-Type': 'multipart/form-data'}" <el-upload class="header__item" action="https://imgkr.com/api/files/upload"
:headers="{'Content-Type': 'multipart/form-data'}"
:show-file-list="false" :multiple="true" accept=".jpg,.jpeg,.png,.gif" name="file" :show-file-list="false" :multiple="true" accept=".jpg,.jpeg,.png,.gif" name="file"
:before-upload="beforeUpload" :on-success="uploaded"> :before-upload="beforeUpload" :on-success="uploaded">
<el-tooltip effect="dark" content="上传图片" placement="bottom-start"> <el-tooltip effect="dark" content="上传图片" placement="bottom-start">
@ -69,6 +70,7 @@ import {
setFontSize, setFontSize,
isImageIllegal isImageIllegal
} from '../../scripts/util' } from '../../scripts/util'
import fileApi from '../../api/file';
import { import {
solveWeChatImage, solveWeChatImage,
solveHtml solveHtml
@ -165,7 +167,15 @@ export default {
}); });
return false; return false;
} }
return true; let fd = new FormData();
fd.append('file', file);
fileApi.fileUpload(fd).then(res => {
this.uploaded(res)
}).catch(err => {
console.log(err.message)
})
return false;
}, },
// //
copy() { copy() {