The problem of reading and displaying image files without Suffixes in the nginx Environment

Source: Internet
Author: User
When I use php to generate some images (without a suffix, it is actually a PNG file), I am prompted to download the images instead of directly displaying the images when reading the images using URLs (loading normally through tags ), how can I set it to display images directly instead of downloading images.

I used php to generate some images (without a suffix, it is actually a PNG file)

When reading with a URL, the system prompts me to download the image instead of directly displaying the image (loading normally through the tag). How can I set it to display the image directly instead of downloading it.

Reply content:

I used php to generate some images (without a suffix, it is actually a PNG file)

When reading with a URL, the system prompts me to download the image instead of directly displaying the image (loading normally through the tag). How can I set it to display the image directly instead of downloading it.

Nginx add_header.

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

There is an ngxHeadersMore nginx extension, you can modify the response header to change the response of your image request to the Content-Type of the response

Location/png {moreSetHeaders 'content-Type: image/png ';}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.