PHP saves Base64 image base64_decode,
PHP supports Base64 very well. The built-in base64_encode and base64_decode are used to encode and decode the image base64.
Encoding: you only need to read the image stream and then encode it with base64_encode.
Decoding is a little troublesome. The reason is that after the image is encoded as a base64 string, the encoding will contain the following characters: data: image/png; base64, it is used for base64 recognition. However, if base64_decode is directly put into php, the format of the final saved image file will be corrupted. The solution is to remove this string of characters first:
$ Base64_string = explode (',', $ base64_string); // capture data: image/png; base64, $ data = base64_decode ($ base64_string [1]) after this comma; // decode the truncated characters using base64_decode file_put_contents ($ url, $ data ); // write and save the file