convert 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:
- Gate::before not working laravel 8
- DependencyResolver/RuleSet.php on line 84
- creat laravel project
- check substring in php
- datetime format laravel
- Allowed memory size of 1610612736 bytes exhausted (tried to allocate 20480 bytes) in phar:///usr/bin/composer/src/Composer/DependencyResolver/RuleSetGenerator.php on line 64
- check if string in string php
- check if letter is in string php
- check if word exist in string
- check lenght phph
- base64_decode() output to header location
- add validation for webp image in laravel
- ->with('success'
- check if the string match in php
- $this- attribute laravel
- array should not be empty php
- count column eloquent laravel
- base64 file php
- Illuminate\Http\Request vs \Illuminate\Support\Facades\Request
- check if value exists in array key php
- echo foreach
- euclid algorithm
- Illuminate\Database\QueryException SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes (SQL: alter table `users` add unique `users_email_unique`(`email`))
- catch an exception within a catch block php