wx.uploadFile方法上传图片,部分图片后台无法获取怎么回事?
发布于 6 年前 作者 taogong 5555 次浏览 来自 官方Issues

// 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) => {},

// })

}

})

},

2 回复

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

手机:华为Y66(DUB-Al00a)

安卓版本8.1.0

微信版本:Version 8.0.20

运行wx.uploadFile方法上传相册里刚刚拍照的照片,后台获取不到(不仅限于刚拍的照片)

回到顶部