base64 to image php
$path = 'myfolder/myimage.png';
$type = pathinfo($path, PATHINFO_EXTENSION);
$data = file_get_contents($path);
$base64 = 'data:image/' . $type . ';base64,' . base64_encode($data);
function base64_to_jpeg($base64_string, $output_file) {
// open the output file for writing
$ifp = fopen( $output_file, 'wb' );
// split the string on commas
// $data[ 0 ] == "data:image/png;base64"
// $data[ 1 ] == <actual base64 string>
$data = explode( ',', $base64_string );
// we could add validation here with ensuring count( $data ) > 1
fwrite( $ifp, base64_decode( $data[ 1 ] ) );
// clean up the file resource
fclose( $ifp );
return $output_file;
}
Also in PHP:
- TRY CAT in php
- comment split une chaine de caratere en php
- check type of result php
- 2 time between add php
- create class with seeder and migration
- error_log wordpress
- csv to json php
- date php string
- create well formated json php
- errors throwing in php
- exceptionhandling php
- change max_execution_time php on script
- array_unique trong php
- date format ph
- 500 error in laravell
- count length of string php
- create file php
- check if a string is in another string python php
- command to download laravel
- check if substring present in string in php
- CURLAUTH_BEARER cannot find
- change readble date format in php
- check if substr exist php
- codeigniter get id after insert