我提到了URL
我正在使用croppie plugin,它在Android,Chrome,Mozilla上运行良好。但不适用于iOS和Safari。如果我从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';
请帮我解决。
答案 0 :(得分:0)