提交 4e550dcd 编写于 作者: H HFO4

修复nginx无法使用sendfile

上级 59f8a9b5
...@@ -867,16 +867,30 @@ class FileManage extends Model{ ...@@ -867,16 +867,30 @@ class FileManage extends Model{
} }
private function sendFile($speed,$range,$download=false,$header="X-Sendfile"){ private function sendFile($speed,$range,$download=false,$header="X-Sendfile"){
$filePath = ROOT_PATH . 'public/uploads/' . $this->fileData["pre_name"];
$realPath = ROOT_PATH . 'public/uploads/' . $this->fileData["pre_name"];
if($header == "X-Accel-Redirect"){
$filePath = '/public/uploads/' . $this->fileData["pre_name"];
}
if($download){ if($download){
$filePath = ROOT_PATH . 'public/uploads/' . $this->fileData["pre_name"];
header('Content-Disposition: attachment; filename="' . str_replace(",","",$this->fileData["orign_name"]) . '"'); header('Content-Disposition: attachment; filename="' . str_replace(",","",$this->fileData["orign_name"]) . '"');
header("Content-type: application/octet-stream"); header("Content-type: application/octet-stream");
header('Content-Length: ' .(string)(filesize($realPath)) );
$filePath = str_replace("\\","/",$filePath); $filePath = str_replace("\\","/",$filePath);
if($header == "X-Accel-Redirect"){
ob_flush();
flush();
echo "s";
}
header($header.": ".str_replace('%2F', '/', rawurlencode($filePath))); header($header.": ".str_replace('%2F', '/', rawurlencode($filePath)));
}else{ }else{
$filePath = ROOT_PATH . 'public/uploads/' . $this->fileData["pre_name"];
$filePath = str_replace("\\","/",$filePath); $filePath = str_replace("\\","/",$filePath);
header('Content-Type: '.self::getMimetype($filePath)); header('Content-Type: '.self::getMimetype($realPath));
if($header == "X-Accel-Redirect"){
ob_flush();
flush();
echo "s";
}
header($header.": ".str_replace('%2F', '/', rawurlencode($filePath))); header($header.": ".str_replace('%2F', '/', rawurlencode($filePath)));
ob_flush(); ob_flush();
flush(); flush();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册