收藏
回答

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

// 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 个回答

  • 08
    08
    2022-03-18

    手机:华为Y66(DUB-Al00a)

    安卓版本8.1.0

    微信版本:Version 8.0.20

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


    2022-03-18
    有用
    回复
  • Cjiang
    Cjiang
    2022-03-18

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

    2022-03-18
    有用
    回复 2
    • 08
      08
      2022-03-18
      其中用拍照上传照片是完全没有问题的!只有选择相册图片才会出现这个问题
      2022-03-18
      回复
    • 08
      08
      2022-03-20
      解决了~相册图片需要经过压缩并且后台设置了图片大小限制
      2022-03-20
      回复
登录 后发表内容