Send binary file in HTTP response using C sockets

前端 未结 4 1600
伪装坚强ぢ
伪装坚强ぢ 2020-12-10 06:44

I`m trying to send a binary file (png image) in http response.

FILE *file;
char *buffer;
int fileLen;

//Open file
file = fopen(\"1.png\", \"rb\");
if (!file         


        
4条回答
  •  再見小時候
    2020-12-10 07:12

    strcat(reply, buffer); // this is incorrect, because png(buffer) may contain zero byte
    send(client, reply, strlen(reply), 0);
    strlen(reply) // this is incorrect, because png may contain zero byte
    

提交回复
热议问题