I am currently working on a utility that pulls files out of an MSSQL database. The body of the files are stored in the database as base64 string which I am decoding with the PHP function base64_decode()
. To begin the file to download when the page opens I am using the headers:
$filename = $file[0][0];
$file_body = base64_decode( $file[0][1] );
$size = $file[0][2];
$type = $file[0][3];
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Description: File Transfer");
header("Content-Length: $size;");
header("Content-Disposition: attachment; filename=$filename");
header("Content-Type: $type ");
header("Content-Transfer-Encoding: binary");
echo $file_body;
Files download and everything works perfect until the file size is over about 48kb. After that only 48kb of the file is downloaded. I have tested using many files types and still have the same result. I have boosted php memory and post size in php.ini at the suggestion of other posts I have found online, still no luck.
I realize PHP may not be the best way to accomplish this, however, this is what I have available to me.
Any ideas how I can ensure a complete file is always downloaded?