Saving a Base64 string to disk as a binary using PHP

前端 未结 8 1485
无人及你
无人及你 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 16:02

    function base64_decode_file($data)
    {
        if(preg_match('/^data\:([a-zA-Z]+\/[a-zA-Z]+);base64\,([a-zA-Z0-9\+\/]+\=*)$/', $data, $matches)) {
            return [
                    'mime' => $matches[1],
                    'data' => base64_decode($matches[2]),
            ];
        }
        return false;
    }
    

提交回复
热议问题