I am using mongodb with php. I have agreement download option on which when user clicks user get the agreemment downloaded. On click i have navigated to script where file download code in php is there code is
$mongoDbA = $mongoDb->findOne(array("agency_id" => new MongoId($_GET['id'])));
$filename = '../../images/upload/'.$mongoDbA['file'];
if (file_exists($filename))
{
header('Content-Description: File Transfer');
header('Content-Type: text/pdf');
header('Content-Disposition: attachment; filename='.basename($filename));
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($filename));
readfile($filename);
exit;
}
I have allowed to upload only pdf files so only pdf files are there in database
When i click then it gives me error & gives me white colored file that has no extension & size is 1 kb hardly....what is happening???