cropper.js upload.php not working(not calling php) please help

here is html code…!

[php]

Cropper.js .label { cursor: pointer; }
.progress {
  display: none;
  margin-bottom: 1rem;
}

.alert {
  display: none;
}

.img-container img {
  max-width: 100%;
}

Upload cropped image to server

avatar
0%
Crop the image
×
Cancel Crop
[/php]

here is php code
[php]
mysqli_error()
$file_to_upload = $_FILES[‘avatar’][‘tmp_name’];
$file_name = ‘cropped.jpg’;
move_uploaded_file($file_to_upload, $file_name);
[/php]

mysqli_error() i put into getting errors ignore that

i’m getting base 64 image but i don’t know to how to save this in to server

Why are you getting a base64 image? I mean, you can save the string to a DB or decode the base64 image and save the file. But I don’t see anything that would do that encoding.

how to do?

actually its calling php here is php code…!
define(‘UPLOAD_DIR’, ‘./upload/’);
$img = $_POST[‘avatar’];
$img = str_replace(‘data:image/jpeg;base64,’, ‘’, $img);
$img = str_replace(’ ', ‘+’, $img);
$data = base64_decode($img);
$file = uniqid() . ‘.jpg’;
$path = UPLOAD_DIR . $file;
$success = file_put_contents($path, $data);
print $success ? $file : ‘Unable to save the file.’;
here i’m getting blank image file! anyone please help…$img=$_POST[‘avatar’] is this correct?

No. The file should come in through $_FILES not $_POST

its not successful…!

https://www.w3schools.com/php/php_file_upload.asp

i don’t know about javascript! how to upload when javascript added into it!

<?php $file_to_upload = $_FILES['avatar']['tmp_name']; $file_name = 'cropped.jpg'; move_uploaded_file($file_to_upload, $file_name); ?>

here is solution

For the asynchronous version, http://blueimp.github.io/jQuery-File-Upload/basic.html is what I use.

select image window open when image clicked how to make this to a icon. popup when a click icons!
[php]
avatar

[/php]

how it pass to icon

[php]
[/php] here nothing happens

blueimp jQuery-File-Uploader used for to upload not to crop i need to crop image so

Sponsor our Newsletter | Privacy Policy | Terms of Service