我有一个纯文本的电子邮件备份文件。如何将附加到其上的文档(PDF,图像,文字文件)检索为普通文件?
--bcaec554d754b0f76a04d9fda578--
--bcaec554d754b0f77204d9fda57a
Content-Type: application/pdf; name="test.pdf"
Content-Disposition: attachment; filename="Otest.pdf"
Content-Transfer-Encoding: base64
X-Attachment-Id: 9ba6310dffca527f_0.1
testfile.pdf
或filename.docx
。你去吧您刚刚使用Base64解码重新创建了丢失的附件。
这是如何在PHP解码到文件中做到这一点
function base64_to_jpeg( $inputfile, $outputfile ) {
/* read data (binary) */
$ifp = fopen( $inputfile, "rb" );
$imageData = fread( $ifp, filesize( $inputfile ) );
fclose( $ifp );
/* encode & write data (binary) */
$ifp = fopen( $outputfile, "wb" );
fwrite( $ifp, base64_decode( $imageData ) );
fclose( $ifp );
/* return output filename */
return( $outputfile );
}
在HTML中,如果您只想在Web /使用HTML中显示
<img src="data:image/png;base64,Your_Base_64_Code_Here">
您可以使用For用作CSS背景:
url('data:image/png;base64,Your_Base_64_Code_Here')