I use cropper.js to crop an image. Cropping and displaying works well.
I now want to upload the image using jQuery's Ajax to the directory /uploads (the permissions are set correctly)
Problem: The image is not uploaded, actually nothing happens.
croppedCanvas = $image.cropper('getCroppedCanvas', {
width: 320,
height: 320,
});
croppedCanvas.toBlob(function (blob) {
var form_data = new FormData();
form_data.append('croppedCanvas', blob);
$.ajax('upload.php', {
type: "POST",
data : form_data,
contentType: false,
cache: false,
processData:false,
mimeType:"multipart/form-data"
}).done(function(res) {
console.log('Upload success');
});
});'
Instead of
$.ajax('upload.php', {
type: "POST",
I also tried to upload directly (like recommended on https://github.com/fengyuanchen/cropper
$.ajax('/uploads', {
type: "POST",
but neither the image is uploaded nor my php-script "upload.php" is executed.
However, the console says "Upload success"