输入banner图图片脚本导航/分类

nginx环境下无后缀图片文件读取显示的问题

我用php生成了一些图片(没有后缀,其实是PNG文件)

用URL读取的时候提示我下载而非直接显示图片(通过标签加载正常),请问我要怎么设置才能直接显示图片,而非下载。

回复内容:

我用php生成了一些图片(没有后缀,其实是PNG文件)

用URL读取的时候提示我下载而非直接显示图片(通过标签加载正常),请问我要怎么设置才能直接显示图片,而非下载。

nginx add_header。

location /images/ {
    add_header content-type "image/png";
}

有个叫 ngxheadersmore 的nginx扩展,可以修改response header 把你图片请求的response,改成响应的Content-Type

location /png {
  moresetheaders 'Content-Type: image/png';
}