PHP Convert an Image File to Base64

Posted on July 23, 2019 at 9:24 am

PHP code snippet to convert an image file to base64:

$base64_image = "data:image/png;base64,".base64_encode(file_get_contents("/path/to/image.png"));

Need to convert a base64-encoded image back to file? Read this:

PHP Convert Base64-Encoded Image to File

Receive updates via email

Other Posts

Updated Posts