php - readfile('filename.exe') and decode base64? -
i'm using php in order stream file download. part of uses readfile
:
<?php // headers etc... // ... readfile('file.exe'); ?>
this binary file, various reasons (that not relevant question) need store file base64 or similar.
how stream file readfile
stored encoded base64?
i guess there many ways lead success here, i'm looking best & convenient.
using stream filters should help:
$infile = 'file.exe'; $outfile = 'php://output'; $inhandle = fopen($infile, 'r'); $outhandle = fopen($outfile, 'w'); stream_filter_append($inhandle, 'convert.base64-decode'); stream_copy_to_stream($inhandle , $outhandle); fclose($inhandle ); fclose($outhandle);
Comments
Post a Comment