iOs Safari:照片预览提供错误的方向

时间:2015-02-18 11:55:21

标签: javascript jquery input orientation mobile-safari

我使用 CSS background-image预览拍摄的照片。 (不是<img src="">

HTML:

<div class="image"></div>
<input type="file" name="upload" id="upload" accept="image/*">
<label for="upload">Upload</label>

CSS:

 .image {
    position: absolute;
    top: 0;
    left: 0;
    width: 300px;
    height: 300px;
    background-size: 100%;
    background-size: cover;
}

JS:

function readImage(el) {
    if (el.files && el.files[0]) {
        var reader = new FileReader();
        reader.onload = function (e) {
            var base64 = e.target.result;
            $('.image').css('background-image', 'url(' + base64 + ')');
        };
        reader.readAsDataURL(el.files[0]);
    }
}

$('#upload').change(function() {
        readImage(this);
});

拍摄照片时,预览会在移动版Safari 上显示错误的方向。谁知道如何解决?任何伎俩?

演示: http://jsfiddle.net/015oek13/

0 个答案:

没有答案