Croppie
Croppie copied to clipboard
Some resulting images are black
Have being using croppie 2.6.2 in a website I have built for a client who has a few hundred clients who can upload profile pics and a handful of people have reported that they have been having trouble with resulting images. So I've downloaded the images from the server and some of those images are just black.
There is no common browser this is occurring on as some have tried on safari version 7.1.6 (9537.85.15.3), chrome Version 67.0.3396.87 and firefox.
Here is the JS that sends the info to the server:
jQuery('.upload-profile-image').on('click', function (ev) {
var id = jQuery("#id").val();
$uploadCropProfile.croppie('result', {
type: 'canvas',
size: {width: 1500, height: 655}
}).then(function (resp) {
jQuery.ajax({
url: "/advertiser/actions/visualeditorajax.php",
type: "POST",
data: {"image":resp, "request":"uploadnewprofileimage", "id":id},
success: function (returned) {
var msg = jQuery.parseJSON(returned);
console.log(msg);
if(msg.status == "success"){
jQuery(".profile-img-container").html(msg.image);
}
jQuery(".croppie-profile-image").hide();
jQuery('html, body').animate({
scrollTop: 0
}, 1000);
}
});
});
});
Then the PHP that handles the save (edited for only the relevant lines) :
$data = $_POST['image'];
list($type, $data) = explode(';', $data);
list(, $data) = explode(',', $data);
$data = base64_decode($data);
$imageName = "image_".time().'.jpg';
$newfilename = $this->update_file_name($imageName, $uploaddir);
file_put_contents($uploaddir.$newfilename, $data);
Any help will be greatly appreciated!
I confirm I have the same issue. Everything is working fine most of the time but sometimes, the image is either totally black or has a big black strip at the bottom.