3
我必須單擊鏈接下載列出的文件,因爲我已經使用了下面的腳本,但是當文件被下載時,它不能識別下載文件的擴展名。那麼,如何獲取要下載的文件的MIME類型? _請幫助...如何獲取要下載的文件的MIME類型?
$filename = $_GET['val'];
// Fetch the file info.
$filePath = $_SERVER['DOCUMENT_ROOT'] . "dfms/images/uploads/".$filename;
if(file_exists($filePath)) {
echo $fileName = basename($filePath);
$fileSize = filesize($filePath);
// Output headers.
header("Cache-Control: private");
header("Content-Type: application/octet");
header("Content-Length: ".$fileSize);
header("Content-Disposition: attachment; filename=".$fileName);
// Output file.
readfile ($filePath);
exit();
}
else {
die('The provided file path is not valid.');
}
它不工作!它給我... 警告:finfo_open()預計參數1要長,在C指定的字符串:\ WAMP \ WWW \第24行的dfms \ support-scripts \ download.php 警告:finfo_file():提供的參數不是第25行中C:\ wamp \ www \ dfms \ support-scripts \ download.php中的有效file_info資源 – 2011-02-11 06:12:55