cyb*_*ave 9 file-upload photo ios
特别是对于Safari,当'拍摄照片或视频'用于我的'input = file accept ='image/*''时,它有时会(大多数情况下)崩溃浏览器/网页.这是一个巨大的问题,因为有7个图像输入需要填充.用户不得不一遍又一遍地尝试是非常令人沮丧的.禁用文件输入的拍照不是一种选择.
我已经尝试使用画布调整图像大小并将其转换为blob.最奇怪的是,它每次都会面向前方100%工作,但后置摄像头是间歇性的.大多数用户使用后置摄像头.我能做出的唯一结论是,这是IOS 8.3(或句号)的一个问题.
适用于IOS,Android甚至Windows Phone的Chrome.对此有任何解决方法吗?
- 更新了Safari Crash Log 6/5/2015
代码示例(使用ng-file-upload)
玉
label.upload(id='img_upload_{{$index}}' accept='image/*;capture=camera', ngf-select, ng-model='r.file', ngf-change='initPhoto($files, $event, $index)') Click to Select Upload
JAVASCRIPT
$scope.initPhoto = function(files, event, index){
if(files.length){
var file = (event.srcElement || event.target).files[0];
var options = {canvas: true};
loadImage.parseMetaData(file, function (data) {
//DOES IT CONTAIN EXIF ORIENTATION DATA?
if (data.exif) {
options.orientation = data.exif.get('Orientation');
}
//LOAD IMAGE INTO $myPreview and $myFile
loadImage(file, function (img) {
img = resizePhoto(img);
file = {};
img.toBlob(function (blob) {
$scope.$apply(function () {
$scope.photoRecords[index].photo = blob;
$scope.photoRecords[index].file = img.toDataURL();
});
}, 'image/jpeg');
}, options);
});
}
};
function resizePhoto(img){
var MAX_WIDTH = 1632;
var MAX_HEIGHT = 1224;
var width = img.width;
var height = img.height;
var canvas = document.createElement('canvas');
if (width > height) {
if (width > MAX_WIDTH) {
height *= MAX_WIDTH / width;
width = MAX_WIDTH;
}
} else {
if (height > MAX_HEIGHT) {
width *= MAX_HEIGHT / height;
height = MAX_HEIGHT;
}
}
canvas.width = width;
canvas.height = height;
var ctx = canvas.getContext('2d');
ctx.drawImage(img, 0, 0, width, height);
return canvas;
}
Run Code Online (Sandbox Code Playgroud)
SAFARI CRASH LOG
Incident Identifier: 429DC524-8B3E-4E0F-9A02-A119239A9D17
CrashReporter Key: 0f890a17d3c01d0dc653fa891ba132f8030c9a06
Hardware Model: iPhone7,1
Process: MobileSafari [14647]
Path: /Applications/MobileSafari.app/MobileSafari
Identifier: com.apple.mobilesafari
Version: 600.1.4 (8.0)
Code Type: ARM-64 (Native)
Parent Process: launchd [1]
Date/Time: 2015-06-05 11:11:14.449 -0500
Launch Time: 2015-06-05 10:49:45.740 -0500
OS Version: iOS 8.3 (12F70)
Report Version: 105
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x0000000000000028
Triggered by Thread: 0
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1062 次 |
最近记录: |