vant 上传附件后回显_Vue + VantUI Uploader 上传组件, 实现上传功能, 但 手机实时上传照片只回显, 上传不上去 。...

电脑浏览器 没有任何问题

手机上操作, 就会出现图片上传不上去, 也没有报错, 怀疑是 没有触发上传事件 , 但又 不知道如何修改, 求大神给个 建议。。

来个Demo 那就好极了

这是前端 页面

这是 js 部分 往后端传 , 切显示图片的// 图片上传

onRead(file) {

console.log(file);

console.log('红红火火恍恍惚惚',file.file);

this.headerImg = file.content;

this.$axios.post("http://192.168.1.241:3721/api/qrresume/savePicture", {

file: file,filename: this.resume.applyerName

}).then(resp => {

if (resp.status == 200) {

if (resp.data.status == 200) {

this.resume.imagePath = resp.data.data;

} else {

this.$Message.error("图片上传失败,请重新上传!");

}

}

})

},

这是后端路路由//保存图片

router.post('/savePicture', async (ctx) => {

let base64 = ctx.request.body.file.content;

let filename = ctx.request.body.filename;

let newFileName = Date.now() + "-" + filename + ".jpg";

var base64Data = base64.replace(/^data:image\/\w+;base64,/, "");

var dataBuffer = new Buffer(base64Data, 'base64');

try {

fs.writeFile(`public/upload/photos/${newFileName}/`, dataBuffer, function(err) {});

ctx.body = {

data: newFileName

}

} catch (error) {

throw error

}

})

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值