Good afternoon,
I'm using the camanjs plugin and I'm not able to save the image to the server, I have the code like this:
<img id="camanimage" src="image.jpg" style="height:200px;">
No javascript:
Caman("#camanimage", function () {
this.brightness(10);
this.contrast(10);
this.render(function(){
//this.save(); Funciona
var imagedata = this.toBase64();
solution: this line was missing to remove the initial part of the data image:
var raw_image_data = imagedata.replace(/^data\:image\/\w+\;base64\,/, '');
$.post("salvafoto.php", { imagedata: raw_image_data },
function(info){
}
);
// ...
Then in salvafoto.php
I have this:
$encodedData = base64_decode($_POST['imagedata']);
$result = file_put_contents( 'teste.jpg', $encodedData );
When you open the image, it is always black with an error. Does anyone know why? If you use this.save()
it downloads but it works.