i我试图在文件末尾使用此插件,并且在HTML之间和HTML之间尝试了此插件,但我遇到了相同的错误。我不知道为什么会发生这种情况。
这里是我的代码
<script src="jquery-3.3.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/croppie/2.6.5/croppie.min.js"></script>
<link rel="stylesheet" type="text/css" href="<?php echo base_url()?>assets/croppie/croppie.css" />
<script type="text/javascript">
$(document).ready(function(){
$image_crop = $('#upload-image').croppie({
enableExif: true,
viewport: {
width: 200,
height: 200,
type: 'square'
},
boundary: {
width: 300,
height: 300
}
});
$('#userPhoto').on('change', function () {
var reader = new FileReader();
reader.onload = function (e) {
$image_crop.croppie('bind', {
url: e.target.result
}).then(function(){
console.log('jQuery bind complete');
});
}
reader.readAsDataURL(this.files[0]);
});
$('#crop').on('click', function (ev) {
$image_crop.croppie('result', {
type: 'canvas',
size: 'viewport'
}).then(function (response) {
$.ajax({
url: "upload.php",
type: "POST",
data: {"image":response},
success: function (data) {
html = '<img src="' + response + '" />';
$("#upload-image-i").html(html);
}
});
});
});
});
</script>
我尝试了一个文件中的所有代码,并且在那里工作正常。
我面临同样的问题。检查CDN.
您必须使用两个链接
(croppie.css and croppie.min.js)
到您尝试上传图像的页面。
cdn
https://cdnjs.com/libraries/croppie