php下载链接返回内部服务器错误

php下载链接返回内部服务器错误,php,Php,我正在尝试在我的表单中创建下载链接,以便人们可以下载上传文件夹中的文件 <?php $path = $_SERVER['DOCUMENT_ROOT']."/content/uploads/"; // change the path to fit your websites document structure $fullPath = $path.basename($_REQUEST['download_file']); if (is_readable ($fullPath))

我正在尝试在我的表单中创建下载链接,以便人们可以下载上传文件夹中的文件

<?php

$path = $_SERVER['DOCUMENT_ROOT']."/content/uploads/"; // change the path to fit your     websites document structure
$fullPath = $path.basename($_REQUEST['download_file']);

if (is_readable ($fullPath)) {
$fsize = filesize($fullPath);
$path_parts = pathinfo($fullPath);
$ext = strtolower($path_parts["extension"]);
switch ($ext) {
    case "pdf"||"docx"||"doc"||"jpg"||"jpeg":
    header(("Content-type: lappication/pdf")||("Content-type: application/msword")||("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/octet-stream");
    header("Content-Disposition: filename=\"".$path_parts["basename"]."\"");
}
header("Content-length: $fsize");
header("Cache-control: private"); //use this to open files directly
readfile($fullPath);
exit;
} else {
        die("Invalid request");
}

检查重定向的位置
$path\u parts[“basename”]
它输出什么?您有:
标题((“内容类型:lappication/pdf”)…
。您是指
标题((“内容类型:appication/pdf”)…
?我认为它指向$\u服务器['DOCUMENT\u ROOT']中的文件。“/Content/uploads/实际上它的内容类型:application/pdf。键入错误。
<h2>Forms Available</h2>

<a href="content/grants/download.php?download_file=some.pdf">Download here</a>
<a href="content/grants/download.php?download_file=">Download here</a>
<a href="content/grants/download.php?download_file=IntroLetter.docx">Download here</a>
<a href="content/grants/download.php?download_file=Conference Grant Application Form.doc">Download here</a>