微信小程序:拍照上传,安卓正常,苹果报错
问题描述
同样是使用 camera组件拍照,然后使用wx.uploadFile()上传服务器识别。
安卓手机工作正常,苹果手机上传图片后,服务器抛回异常500.
解决方案
camera的尺寸设置偏小,略微调整camera的height属性后,问题解决。
本次调节具体值为:600rpx存在问题,700rpx解决问题。
通过iPhone6测试。
<camera device-position="back" flash="off" binderror="error" style="width:100%;height:700rpx;" />
takePhoto() {
var that = this;
const ctx = wx.createCameraContext();
ctx.takePhoto({
quality: 'normal', //'low',//'high',
success: (res) => {
console.log(res.tempImagePath);
。。。。
wx.uploadFile({
url: 'http://xxxxxxx',
filePath: res.tempImagePath,
name: 'file',
。。。
另外,quality: 'normal'替换为'high' 无法解决上述问题。
问题原因
猜测:苹果生成的文件大小过小,服务器不识别。