iOS 8.3 Safari在输入类型=文件

时间:2015-06-04 21:19:09

标签: ios file-upload photo

专门针对Safari,当拍摄照片或视频时#39;用于我的输入=文件接受='图像/ *'',它会使浏览器/网页崩溃有时(大多数情况下) 。这是一个巨大的问题,因为有7个图像输入需要填充。用户不得不一遍又一遍地尝试是非常令人沮丧的。禁用文件输入的拍照是一个选项。

我尝试使用画布调整图像大小并将其转换为blob。最奇怪的是,它每次都会面向前方100%工作,但后置摄像头是间歇性的。大多数用户使用后置摄像头。我能做出的唯一结论是它是IOS 8.3(或句号)的问题。

适用于IOS,Android甚至Windows Phone的Chrome。对此有任何解决方法吗?

- 更新了Safari Crash Log 6/5/2015

代码示例(使用ng-file-upload)

JADE 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;
}

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

0 个答案:

没有答案