开发者

PHP: base64 image string to image reference

开发者 https://www.devze.com 2023-04-07 01:26 出处:网络
How do I take an base64 string image and covert it to a image reference.The base64 string is sent via ajax.I\'m not sure if image reference is the correct terminology so I\'ll provide an example.

How do I take an base64 string image and covert it to a image reference. The base64 string is sent via ajax. I'm not sure if image reference is the correct terminology so I'll provide an example.

#original method
$newImg = imagecreatefromjpeg($oImg);

#n开发者_C百科ew method
$newImg = imagecreatefromjpeg($base64String);  //THIS IS NOT CORRECT


$data = base64_decode($base64String);

$image = imagecreatefromstring($data);

In this example, imagecreatefromstring() doesn't refer to an actual string of letters in the PHP sense, but rather a blob of data/bytes.

0

精彩评论

暂无评论...
验证码 换一张
取 消