Answer the question
In order to leave comments, you need to log in
How to convert an image to a byte array?
As follows, I accept the file in the controller and save the picture without problems.
Controller:
$img = $_POST['imgBase64'];
echo base64_decode($img);
$img = str_replace('data:image/png;base64,', '', $img);
$img = str_replace(' ', '+', $img);
$data = base64_decode($img);
$file = "tmp/".md5(microtime()).".png";
$success = file_put_contents($file, $data);
var dataURL = canvas[0].toDataURL();
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question