简体   繁体   中英

How to send a image to a client from my HTTP Server?

I am building a small http server. I am able to send html,css,xml files to the client over HTTP. But I am not able to send image files-.jpg,.png.gif. How do I send it so the browser is able to display the image.

Thanks.

Send it just like any other (binary-data) file, with the correct Content-Type and Content-Length headers.

Content-Type for:

  • JPEG: image/jpeg
  • PNG: image/png
  • GIF: image/gif

您可能应该正确设置图像的MIME类型。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM