I think that it should be:
$path="myfolder/myimage.png";
$type = pathinfo($path, PATHINFO_EXTENSION);
$data = file_get_contents($path);
$base64 = 'data:image/' . $type . ';base64,' . base64_encode($data);
More Related Contents:
- PHP – get base64 img string decode and save as jpg (resulting empty image )
- How to provide dynamic HTML in PHP?
- inserting image in database using php [closed]
- How to save a PNG image server-side, from a base64 data URI
- Convert Base64 string to an image file? [duplicate]
- Slowness found when base 64 image select and encode from database
- Output an Image in PHP
- Creating a thumbnail from an uploaded image
- Copy Image from Remote Server Over HTTP
- Base64 Encoding Image
- PHP: How to check if image file exists?
- Super fast getimagesize in php
- Add ‘Watermark’ to images with php [closed]
- Calculating image size ratio for resizing
- best way to determine if a URL is an image in PHP
- RGB to HSV in PHP
- Automatic image format detection in PHP
- How to merge transparent PNG with image using PHP?
- Sending images from Canvas elements using Ajax and PHP $_FILES
- Get image color
- php GD create a transparent png image
- Php : Convert a blob into an image file
- PHP : binary image data, checking the image type
- PHP crop image to fix width and height without losing dimension ratio
- Android post Base64 String to PHP
- PHP to store images in MySQL or not?
- PHP upload image
- TCPDF error :Unable to get the size of the image
- the dreaded “Warning: imagecreatefromjpeg() : ‘/tmp/filename’ is not a valid JPEG file in /phpfile.php on line xxx”
- Fix iOS picture orientation after upload PHP