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
You probably should set correctly the MIME type of your image.
精彩评论