問題描述
同樣是使用 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' 無法解決上述問題。
問題原因
猜測:蘋果生成的文件大小過小,服務器不識別。