Answers for "php base64 file"

PHP
1

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; 
}
Posted by: Guest on July-07-2020
0

php base64

$base_string = base64_encode("your-string"); //for base64 encoding
echo base64_decode($base_string); //for base64 decoding
Posted by: Guest on October-20-2021

Browse Popular Code Answers by Language