PeakTai / vue-html5-editor

An html5 wysiwyg editor for vue
Apache License 2.0
949 stars 247 forks source link

图片上传的时候想用二进制 #135

Open ghost opened 5 years ago

ghost commented 5 years ago

默认的是base64 , 如何得到二进制数据然后上传?新加一个按钮,点按钮再上传图片,如何拿到压缩后的图片数据?

ghost commented 5 years ago

正常上传了,上传后返回的链接怎么插到内容里面?

yangyongguan commented 5 years ago

image: { sizeLimit: 512 * 1024, compress: null, uploadHandler (responseText) { var json = JSON.parse(responseText) if (json.code !== 200) { console.error(json.msg) } else { if (json.data.host.indexOf('http') !== 0) { return 'https://' + json.data.host + '/' + json.data.name } return json.data.host + '/' + json.data.name } }, upload: { url: '/api/upload/image', headers: {}, params: {}, fieldName: 'file' } },

yangyongguan commented 5 years ago

在uploadHandler 回调里面拿到服务器返回的数据自己处理