|
...
|
...
|
@@ -64,16 +64,13 @@ class FileManageController extends BaseController |
|
|
|
*/
|
|
|
|
public function downLoad()
|
|
|
|
{
|
|
|
|
// 检查参数
|
|
|
|
if (!isset($this->param['path']) || empty($this->param['path'])) {
|
|
|
|
$this->response('参数错误', Code::SYSTEM_ERROR);
|
|
|
|
if(!isset($this->param['path']) || empty($this->param['path'])){
|
|
|
|
$this->response('参数错误',Code::SYSTEM_ERROR);
|
|
|
|
}
|
|
|
|
// 获取文件名和 URL
|
|
|
|
$username = basename($this->param['path']);
|
|
|
|
$parsed_url = parse_url($this->param['path']);
|
|
|
|
$fileUrl = isset($parsed_url['scheme'])
|
|
|
|
? $this->param['path']
|
|
|
|
: 'https://file.globalso.com' . $this->param['path'];
|
|
|
|
if(isset($parsed_url['scheme'])){
|
|
|
|
$fileUrl = $this->param['path'];
|
|
|
|
// 获取文件头信息
|
|
|
|
$headers = get_headers($fileUrl, 1);
|
|
|
|
if ($headers === false || !isset($headers['Content-Length'])) {
|
|
...
|
...
|
@@ -121,6 +118,15 @@ class FileManageController extends BaseController |
|
|
|
}
|
|
|
|
curl_close($ch);
|
|
|
|
exit;
|
|
|
|
} else {
|
|
|
|
$fileUrl = 'https://file.globalso.com'.$this->param['path'];
|
|
|
|
// 设置响应头
|
|
|
|
header('Content-Description: File Transfer');
|
|
|
|
header('Content-Type: application/octet-stream');
|
|
|
|
header('Content-Disposition: attachment; filename="' . $username . '"');
|
|
|
|
// 下载文件
|
|
|
|
readfile($fileUrl);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
...
|
...
|
|