微信小程序:拍照上传,安卓正常,苹果报错


问题描述

同样是使用 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' 无法解决上述问题。

 

问题原因

猜测:苹果生成的文件大小过小,服务器不识别。

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM