<?php
if( isset($_GET['filename']) &&  $_GET['filename']!='' ){

$fileToSend ='../upload/resume/'.$_GET['filename'];

if(file_exists($fileToSend)){

 $fsize = filesize($fileToSend);
    $path_parts = pathinfo($fileToSend);
    $ext = strtolower($path_parts["extension"]);
    switch ($ext) {
        case "pdf":
        header("Content-type: application/pdf"); // add here more headers for diff. extensions
        header("Content-Disposition: attachment; filename=\"".$path_parts["basename"]."\""); // use 'attachment' to force a download
        break;
		case "docx":
        header("Content-type: application/msword"); // add here more headers for diff. extensions
        header("Content-Disposition: attachment; filename=\"".$path_parts["basename"]."\""); // use 'attachment' to force a download
        break;
		case "doc":
        header("Content-type: application/msword"); // add here more headers for diff. extensions
        header("Content-Disposition: attachment; filename=\"".$path_parts["basename"]."\""); // use 'attachment' to force a download
        break;
		case "jpg":
        header('Content-type: image/jpeg'); // add here more headers for diff. extensions
        header("Content-Disposition: attachment; filename=\"".$path_parts["basename"]."\""); // use 'attachment' to force a download
        break;
        default;
        header("Content-type: application/vnd.ms-word");
        header("Content-Disposition: filename=\"".$path_parts["basename"]."\"");
		}
		
readfile($fileToSend);
?>
	<script>
	window.close();
	</script>
	<?php
}else{
?>
	<script>
	window.close();
	</script>
	<?php
}
}else{
echo "File not found.";
	?>
	<script>
	window.close();
	</script>
	<?php
}
?>
 