PDF文件下载错误PHP

I have used below code for downloading my pdf file in PHP.

my problem is when i download file it display error File type HTML document (text/html) is not supported. if i download direct from server it can be open. Please solve my issue.

$path = ""; 


if (is_readable ($Path)) {
$fsize = filesize($Path);
$path_parts = pathinfo($Path);
$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"]."\"");     
    break;
    default:

}
header("Content-length: $fsize");
header("Cache-control: private"); //use this to open files directly
readfile($Path);

} else {
        die("Invalid request");
}

Your code seems correct apart from one mistake. PHP variables are case sensitive.

Correct your $path variable to $Path.

And also cross check the directory and file permission.