Croppie插件不从事iOS和Safari



我转到此url

我正在使用Croppie插件,并且在Android,Chrome,Mozilla上工作正常。但不从事iOS和野生动物园工作。如果我从iOS上传了图像,则它将获得90*旋转。另外,图像没有在Safari上上传。这是我的完整代码

html

<div class="container">
    <div class="panel panel-default">
      <div class="panel-heading">Image Upluad</div>
      <div class="panel-body">
        <div class="row">
            <div class="col-md-4 text-center">
                <div id="upload-demo" style="width:350px"></div>
            </div>
            <div class="col-md-4" style="padding-top:30px;">
                <strong>Select Image:</strong>
                <br/>
                <input type="file" id="upload">
                <br/>
                <button class="btn btn-success upload-result">Upload Image</button>
            </div>
            <div class="col-md-4" style="">
                <div id="upload-demo-i" style="background:#e1e1e1;width:300px;padding:30px;height:300px;margin-top:30px"></div>
            </div>
        </div>
      </div>
    </div>
</div>

JS

<script type="text/javascript">
$uploadCrop = $('#upload-demo').croppie({
    enableExif: true,
    viewport: {
        width: 200,
        height: 200,
        type: 'circle'
    },
    boundary: {
        width: 300,
        height: 300
    }
});
$('#upload').on('change', function () { 
    var reader = new FileReader();
    reader.onload = function (e) {
        $uploadCrop.croppie('bind', {
            url: e.target.result
        }).then(function(){
            console.log('jQuery bind complete');
        });
    }
    reader.readAsDataURL(this.files[0]);
});
$('.upload-result').on('click', function (ev) {
    $uploadCrop.croppie('result', {
        type: 'canvas',
        size: 'viewport'
    }).then(function (resp) {
        $.ajax({
            url: "/ajaxpro.php",
            type: "POST",
            data: {"image":resp},
            success: function (data) {
                html = '<img src="' + resp + '" />';
                $("#upload-demo-i").html(html);
            }
        });
    });
});
</script>

ajaxpro.php

$data = $_POST['image']; list($type, $data) = explode(';', $data);
list(, $data) = explode(',', $data); $data = base64_decode($data);
$imageName = time().'.png'; file_put_contents('upload/'.$imageName, $data);
echo 'done';

请帮助我修复。

我找到了解决方案。

enableExif需要在文档中所述的Exif.js:http://foliotek.github.io/croppie/#enableexif

添加在所有设备上都可以正常工作后。

相关内容

  • 没有找到相关文章

最新更新