Saving a Base64 string to disk as a binary using PHP

前端 未结 8 1484
无人及你
无人及你 2020-12-24 15:01

As a \"look under the covers\" tutorial for myself I am building a PHP script to gather emails from a POP3 mailbox. While attempting to make use of binary attachments I am

8条回答
  •  生来不讨喜
    2020-12-24 15:41

    If you have a lot of data to write out that needs to be decoded before writing I would suggest using stream filters so decode the data as you write it...

    $fh = fopen('where_you_are_writing', 'wb');
    stream_filter_append($fh, 'convert.base64-decode');
    
    // Do a lot of writing here. It will be automatically decoded from base64.
    
    fclose($h);
    

提交回复
热议问题