Answers for "How to download canvas image into database"

0

How to download canvas image into database

//ajax;;;;;;;;;;
save.click((e)=>{
    var data = canvas.toDataURL('image/png');
    $.post('save.php',{'img':data},function(e){
        console.log(e);
    })
})
//php
<?php
$data = $_POST['img'];
$file = "data/file.png"; // where you want to upload, file path;;;;;
$uri = substr($data,strpos($data, ",") + 1);
file_put_contents($file, base64_decode($uri));
echo $file;
?>
Posted by: Guest on May-06-2021

Code answers related to "How to download canvas image into database"

Code answers related to "Javascript"

Browse Popular Code Answers by Language