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


#1

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]


#2

mysqli_error() i put into getting errors ignore that


#3

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


#4

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.


#5

how to do?


#6

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?


#7

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


#8

its not successful…!


#9

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


#10

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


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

here is solution


#12

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


#13

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


#14

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