search

Home  >  Q&A  >  body text

html5 - 为什么没有后缀名的图片可以在网页中显示?

http://cdn.aixifan.com/dotnet...
这个图片在网页上是没有后缀名的,下载下来是gif,请问是怎么实现的?

大家讲道理大家讲道理2785 days ago1242

reply all(3)I'll reply

  • 怪我咯

    怪我咯2017-04-17 14:30:55

    is shown below because of the Content-Type: image/gif header.

    $ curl -I -X GET http://cdn.aixifan.com/dotnet/artemis/u/cms/www/201512/18171819tvawkism.gif?imageView2/1/w/40/h/40
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
      0 44199    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0HTTP/1.1 200 OK
    Date: Wed, 30 Nov 2016 14:49:22 GMT
    Content-Type: image/gif
    Content-Length: 44199
    Connection: keep-alive
    Expires: Wed, 24 May 2017 04:00:09 GMT
    Server: nginx/1.8.0
    Last-Modified: Fri, 18 Dec 2015 09:16:24 GMT
    ETag: "5673cee8-aca7"
    Cache-Control: max-age=20736000
    Accept-Ranges: bytes
    X-Ser: BC81_dx-lt-hebei-shijiazhuang-2-cache-1, BC79_dx-beijing-beijing-4-cache-1, BC250_KR-seoul-seoul-1-cache-2, BC136_SG-singapore-singapore-1-cache-1
    
    

    Moreover, the reason why the pictures you usually see are displayed as pictures by the browser is usually because the web server such as apache or nginx outputs the MIME-Type for you, or because it is written in <img src="xxx">. Please check the nginx configuration: include /etc/nginx/mime.types; Among them, /etc/nginx/mime.types this file records the association between most common file extensions and MIME types. If the file suffix requested by the client is in this file, nginx will output the corresponding content-type header for you.

    If your doubts are answered, please accept it

    reply
    0
  • 怪我咯

    怪我咯2017-04-17 14:30:55

    ? Isn’t the previous one .gif? The previous gif already represents the suffix of the file
    ? The following content is called passing parameters

    Besides, just output the header of Content-Type: image/gif Content-Type: image/jpg, even if the suffix is ​​php,
    for example: https://www.load-page.com/base/attachment?id=777

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-04-17 14:30:55


    See?

    And even if there is no suffix, the gateway server (apache/nginx) can help you find the image. In Linux, files are not distinguished by file name suffixes.

    reply
    0
  • Cancelreply