<?php
ob_clean();
$document_id = $_REQUEST["document_id"];
if(isset($_REQUEST["download_for"]) && $_REQUEST["download_for"] =="appointment_document"){
	$document = utility::getTableFieldById('appointment_document','appointment_document','id',$document_id);
	$uploaddir = '../appointment_document/';
}

$uploaded_file = $uploaddir . $document;

if (file_exists($uploaded_file)) {	
    header('Content-Description: File Transfer');
    header('Content-Type: application/octet-stream');
    header('Content-Disposition: attachment; filename="'.basename($uploaded_file).'"');
    header('Expires: 0');
    header('Cache-Control: must-revalidate');
    header('Pragma: public');
    header('Content-Length: ' . filesize($uploaded_file));
    readfile($uploaded_file);
    exit;
}
?>