为什么PHP函数header()对远程服务器上的图像不起作用?

时间:2020-07-31 04:21:08

标签: php apache

我有这个代码

header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: POST, GET, PUT, DELETE');
use app\components\FilesHandler;

$mimeType = FilesHandler::getType();
header("Content-Type: $mimeType");
echo FilesHandler::getFile();

在本地计算机上,映像具有CORS标头,尽管它不在远程服务器上。 我该如何解决?


来自远程服务器的响应头

Accept-Ranges: bytes
Cache-Control: max-age=315360000
Content-Length: 1521987
Content-Type: image/png
Date: Fri, 31 Jul 2020 05:07:17 GMT
ETag: "5f239615-173943"
Expires: Thu, 31 Dec 2037 23:55:55 GMT
Last-Modified: Fri, 31 Jul 2020 03:55:01 GMT
Server: nginx

来自本地主机的响应头

Access-Control-Allow-Methods: POST, GET, PUT, DELETE
Access-Control-Allow-Origin: *
Connection: Keep-Alive
Content-Type: image/png
Date: Fri, 31 Jul 2020 03:53:10 GMT
Keep-Alive: timeout=120, max=1000
Server: Apache
Transfer-Encoding: chunked
X-Xdebug-Profile-Filename: D:\traces\cachegrind.out.13336

0 个答案:

没有答案