I'm building an application to force downloads of files from the server using the following function:
Code: Select all
function downloadFile($fileName, $path)
{
ob_clean();
header('Content-Description: File Transfer');
header('Content-Type: application/force-download');
header('Content-Length: ' . filesize($path.$fileName));
header('Content-Disposition: attachment; filename=' . $fileName . '');
header("Cache-Control: cache, must-revalidate");
header('Pragma: ');
$contents = file_get_contents($path.$fileName);
echo $contents;
ob_end_flush();
}Thanks.