作者 lyh

gx

... ... @@ -257,6 +257,7 @@ class ImageController extends Controller
* @time :2023/7/19 17:59
*/
public function download(){
$this->setHeader();
$imageModel = new ImageModel();
$info = $imageModel->read(['hash' => $this->param['hash']]);
if ($info === false) {
... ... @@ -280,6 +281,19 @@ class ImageController extends Controller
readfile($fileUrl);
}
public function setHeader(){
// 设置跨域请求头部
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET');
header('Access-Control-Allow-Headers: Content-Type');
// 处理预检请求
if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') {
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET');
header('Access-Control-Allow-Headers: Content-Type');
exit;
}
}
/**
* @param $msg
* @param string $code
... ...