2015-11-08 101 views
-1

我想共享放置在我的服務器的第二個HDD上的文件。這時我用/改編下面的腳本:從我的服務器的第二個HDD下載文件

$file_path = $DLPath."/$file";//$_REQUEST['file']; 
header("Pragma: public"); 
header("Expires: -1"); 
header("Cache-Control: public, must-revalidate, post-check=0, pre-check=0"); 
header("Content-Disposition: attachment; filename=\"$file_name\""); 

// set appropriate headers for attachment or streamed file 
if ($is_attachment) 
    header("Content-Disposition: attachment; filename=\"$file_name\""); 
else 
    header('Content-Disposition: inline;'); 

// set the mime type based on extension, add yours if needed. 
$ctype_default = "application/octet-stream"; 
$content_types = array(
    "exe" => "application/octet-stream", 
    "zip" => "application/zip", 
    "mp3" => "audio/mpeg", 
    "mpg" => "video/mpeg", 
    "avi" => "video/x-msvideo", 
); 
$ctype = isset($content_types[$file_ext]) ? $content_types[$file_ext] : $ctype_default; 
header("Content-Type: " . $ctype); 

$DLPath是絕對路徑(到/ mnt/disk100)。

我認爲在「標題」調用中發生錯誤。但我不知道我該如何處理這件事。

+0

'MNT/disk100'不絕對。 '/ mnt/disk100'爲 –

+0

對不起,這是一個複製/粘貼錯誤... – PM84

+0

是'$ file_name'定義的?另外,錯誤日誌中是否有相關的信息? –

回答

0

這可能是從Apache2SElinux的許可錯誤。

要繞過這一點,你可以設置一個symlink

ln -s /mnt/disk100 /path/to/your/www/root/directory/disk100 

和讀取這個位置

這也可能是幫助文件:SElinux tutorial (jumped to section 5.1)

相關問題