Below is the code I am using to stream a non-web facing file to a browser for download. The file received is a match on the number of bytes however when I do a CRC check of the file, it's different. Any ideas on where I am going wrong?
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: '.filesize($dir));
flush();
$file = fopen($dir, "r");
$size = filesize($dir);
while (!feof($file))
{
if ($size > 1048576)
{
print fread($file, 1048576);
$size = $size - 1048576;
}
else
{
print fread($file, $size);
}
flush();
}
fclose($file);
exit;