public static function DownloadFile()
 {
     $id = intval(Input::get('file_id'));
     $fileInfo = File::whereId($id)->whereBanned(false)->first();
     if ($fileInfo == null) {
         abort(404);
     }
     $config = Config::whereKey('file_dir')->whereApplied(true)->first();
     $sourceFile = $config->value . $fileInfo->file_path;
     $outFile = $fileInfo->filename;
     if (!is_file($sourceFile)) {
         abort(404);
     }
     LogController::LogDownload($id);
     $len = filesize($sourceFile);
     //获取文件大小
     $filename = basename($sourceFile);
     //获取文件名字
     $ctype = FileDownloadController::GetFileExtension($outFile);
     //echo $outFile;
     header("Cache-Control: public");
     header("Content-Type: {$ctype}");
     header("Content-Disposition: attachment; filename=" . $outFile);
     header("Accept-Ranges: bytes");
     $size = filesize($sourceFile);
     $range = 0;
     if (isset($_SERVER['HTTP_RANGE'])) {
         list($a, $range) = explode("=", $_SERVER['HTTP_RANGE']);
         str_replace($range, "-", $range);
         $size2 = $size - 1;
         //文件总字节数
         $new_length = $size2 - $range;
         header("HTTP/1.1 206 Partial Content");
         header("Content-Length: {$new_length}");
         header("Content-Range: bytes {$range}{$size2}/{$size}");
     } else {
         $size2 = $size - 1;
         header("Content-Range: bytes 0-{$size2}/{$size}");
         header("Content-Length: " . $size);
     }
     $fp = fopen("{$sourceFile}", "rb");
     fseek($fp, $range);
     while (!feof($fp)) {
         set_time_limit(0);
         print fread($fp, 1024 * 8);
         flush();
         ob_flush();
     }
     fclose($fp);
     exit;
 }