I'm currently trying to download a blob archive file saved in the database
$fid = $_GET['fid'];
$sel = $wpdb->get_results( "SELECT * FROM uploads WHERE id = $fid" );
foreach( $sel as $head )
{
$name = $head->name;
$type = $head->type;
$size = $head->size;
$content = $head->content;
header("Content-length: $size");
header("Content-type: $type");
header("Content-Transfer-Encoding: Binary");
header("Content-Disposition: attachment; filename=$name");
echo $content;
exit;
}
every time I redirect to /download?id=
with int value assigned to id
it loads the file. However, instead of the browser prompting for file download location, the page reads the binary contents of the blob and displays it all as a string.
any other way of downloading a blob on wordpress?