开发者

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

开发者 https://www.devze.com 2023-03-24 23:53 出处:网络
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

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


You probably should set correctly the MIME type of your image.

0

精彩评论

暂无评论...
验证码 换一张
取 消