wx.uploadFile方法上传图片,部分图片后台无法获取怎么回事?

文章目录

2小时前小编发现微信小程序用户:【08】提出了一个关于“wx.uploadFile方法上传图片,部分图片后台无法获取怎么回事?”的问题,在问题中开发者08对该问题做了如下阐述:


  • API和组件:

// that.showBack();

wx.chooseImage({

count: 1,

sizeType: [‘original‘],

sourceType: [‘camera‘],

success (res) {

// tempFilePath可以作为img标签的src属性显示图片

const tempFilePaths = res.tempFilePaths;

if(isAlbum == ‘1‘){

isChange = true;

}

that.setData({

‘isChange‘:isChange,

‘imageSrc‘:tempFilePaths,

});

that.uploadImg(this.data.imageSrc,this.data.resType);

}

})

//上传图片

uploadImg:function (filePath,number) {

// wx.showLoading({

// title: ‘上传中’,

// mask:true,

// })

console.log(‘上传图片路劲‘);

console.log(filePath[0]);

console.log(‘第二个路径‘);

console.log(this.data.imageSrc[0]);

var that = this;

var resType = number;

var tempFile = filePath;

// var resType = that.data.resType;

wx.uploadFile({

filePath: this.data.imageSrc[0],

url:baseURL + ‘/fillinPersonalPhoto‘,

name:’file‘,

formData:{

uid:wx.getStorageSync(‘uid‘),

pid:that.data.pid,

xuhao:that.data.resType,

},

success:function (res) {

console.log(‘上传图片成功‘);

wx.showToast({

title: ‘上传成功‘,

icon:’none‘

})

// var isAlbum = that.data.isAlbum;

var isChange = false;

var typeFile = ”;

var typeClick = ”;

var typeWidth = ‘0‘;

var typeHeight = ‘0‘;

if(resType == ‘1‘){

typeFile = ‘topImgFile‘;

typeClick = ‘isTopClick‘;

typeWidth = ‘topWidth‘

typeHeight = ‘topHeight‘

}else if(resType == ‘2‘){

typeFile = ‘normalImgFile‘;

typeClick = ‘isNormalClick‘;

typeWidth = ‘normalWidth‘

typeHeight = ‘normalHeight‘

}else if(resType == ‘3‘){

typeFile = ‘gestureImgFile‘;

typeClick = ‘isGestureClick‘;

typeWidth = ‘gestureWidth‘

typeHeight = ‘gestureHeight‘

}

that.setData({

[typeWidth]:’100%‘,

[typeHeight]:’100%‘,

[typeClick]:true,

[typeFile] : tempFile,

// ‘isChange’:isChange,

}),

that.getAllClick();

console.log(res);

var data = JSON.parse(res.data);

console.log(data);

},

fail:function (res) {

console.log(‘上传失败‘);

// wx.hideLoading({

// success: (res) => {},

// })

wx.showToast({

title: ‘上传失败‘,

icon:’none‘

})

console.log(res);

},

complete:()=>{

console.log(‘图片上传complete‘);

wx.showToast({

title: ‘上传成功‘,

icon:’none‘

})

// wx.hideLoading({

// success: (res) => {},

// })

}

})

},

注:以上是微信小程序开发者:”08″对于本问题的一些阐述,这里做一个引用,我们将实时关注微信小程序助手对该问题提出的解决方案。

【1小时前】微信小程序技术运营专员对用户08提出的wx.uploadFile方法上传图片,部分图片后台无法获取怎么回事?给予如下回复

你好,麻烦提供出现问题的具体机型、微信版本号、系统版本号,以及能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)

微信官方智能小程序开源联盟对于整个行业而言是一次机遇,让所有人都有机会享受到小程序所到来的红利。另一方面,对于微信官方自身而言,智能小程序开源联盟或许是其又一次业绩腾飞的潜在动力

如果您也在使用微信小程序,请关注我们,如果您有关于微信小程序的使用问题请关注我们,如果您要找百度小程序模板、微信小程序模板请关注小程序模板网或者去微信开放社区找官方人员给予解决,相信微信官方在小程序上的发力会是一个里程碑!

站内搜索