使用IOS设备比如IPHONE苹果手机或者平板电脑上传图片时,到后台总是会发现图片又翻转的现象,可以使用Exif.js 读取图像的原始数据的功能扩展,例如:拍照方向、相机设备型号、拍摄时间、ISO 感光度、GPS 地理位置等数据。然后根据拍照方向在客户端调整图片方向就可以了。
最佳解决方案
//此处省略HTML var Orientation = null; var canvasHead = ''; $('#fileBtn').on('change',function(){ var files = this.files[0]; var reader = new FileReader(); if(typeof FileReader == 'undefined'){ require('module/common/dialog').showToast('抱歉,您手机暂不支持'); return; }else{ reader.readAsDataURL(files); } reader.onloadstart = function(){ require('module/common/dialog').showLoading('正在读取'); }; reader.onabort = function(){ require('module/common/dialog').hideLoading(); require('module/common/dialog').showToast('读取中断,请重试'); return false; }; reader.onerror = function(){ require('module/common/dialog').hideLoading(); require('module/common/dialog').showToast('读取发生错误,请重试'); return false; }; reader.onload = function(){ require('module/common/dialog').hideLoading(); require('module/common/dialog').showLoading('读取完成,玩命加载中'); if(reader.readyState == 2){ var fileStr = reader.result; var image = new Image(); image.src = fileStr; image.onload = function(){ $('#preHead').addClass('preHead'); var preHead_canva