trying to crop and save image with croppie library not from ajax but from for data because i have another data to send , Image cropped and saved in database but it is corrupted
enter image description hereenter image description here
there are my controller and js code
<div class="col-md-6">
<div class="form-group">
<label> {{trans('words.upload_about_img')}}</label> <br>
<label>Select File</label>
<label id="projectinput7" class="file center-block">
<input type="file" name="image" id="image-input" accept="image/*">
<input type="hidden" name="cropped-image" id="cropped-image-input">
<span class="file-custom"></span>
</label>
</div>
</div>
<div class="row" id="image-container">
</div>
// Initialize Croppie image
var image = $('#image-container').croppie({
enableExif: true,
viewport: {
width: 200,
height: 200,
type: 'square'
},
boundary:{
width:400,
height:400
}
});
// Bind update event to update hidden input with cropped image data
image.on('update', function (croppedImage) {
$('#cropped-image-input').val(croppedImage);
});
// When file input changes, load the image into the Croppie container
$('#image-input').on('change', function () {
var input = this;
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
image.croppie('bind', {
url: e.target.result
});
}
reader.readAsDataURL(input.files[0]);
}
});
$imageData = $request->input('cropped-image');
$imageName = uniqid() . '.png';
$imagePath = public_path('images/' . $imageName);
file_put_contents($imagePath, base64_decode(str_replace('data:image/png;base64,', '', $imageData)));
$about = About::create([
'id' => Auth::id(),
'description' => $request->description,
'about_img' => 'images/'.$imageName,
'mission' => $request->mission,
'vision' => $request->vision,
'our_value' => $request->our_value,
]);