Decoding a canvas todataURL

前端 未结 4 1208
深忆病人
深忆病人 2020-12-07 03:06

I\'m having difficulty using data created with canvas\'s todataurl() method. Currently my code sends the resulting data to my php server which uses the file_put_contents() m

4条回答
  •  旧时难觅i
    2020-12-07 03:21

    Other solutions did not work for me.

    This works:

    //image sample
    $baseFromJavascript = "data:image/png;base64,BBBFBfj42Pj4";
    
    // remove the part that we don't need from the provided image and decode it
    $data = base64_decode(preg_replace('#^data:image/\w+;base64,#i', '', $baseFromJavascript));
    

提交回复
热议问题