Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php base64img to file

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; 
}
Comment

PREVIOUS NEXT
Code Example
Php :: nav active in laravel 
Php :: wordpress remove user roles 
Php :: sortbydesc on a collection laravel 
Php :: add custom user meta and display it in user page 
Php :: laravel date default now 
Php :: laravel serve in another port 
Php :: php add to associative array 
Php :: composer autoload psr-4 
Php :: require all files in directory php 
Php :: is home page if wordpress 
Php :: unable to locate package php8.1 ubuntu 
Php :: post type taxonomy loop wordpress 
Php :: case inside laravel query 
Php :: php include and require statements 
Php :: phpmailer send attachment 
Php :: php mysql insert date time 
Php :: laravel make directory 
Php :: eloquent model sort by ascending order 
Php :: password required wp 
Php :: acf php fields 
Php :: laravel migrate seed 
Php :: php get data from prepared select 
Php :: laravel php artisan tinker test email 
Php :: laravel migration two primary key 
Php :: return last inserted id in laravel 
Php :: php sql query where in array 
Php :: random array php 
Php :: ubuntu install lamp and phpmyadmin 
Php :: laravel query by relationship 
Php :: ubuntu install php 8 mysql 
ADD CONTENT
Topic
Content
Source link
Name
9+6 =