开发者

CURLOPT_POSTFIELDS CURL post image file, C language

Wonder if an开发者_如何学编程yone has any experience posting image files with CURL in C..?

I am writing a program to post to a facebook Type web service, and everything is going fine, except when I attempt to post image files...

There's a special format that the server needs or it will not accept the post...

something like this:

---webformkitXXXXXXXX\r\n filename"somefile.jpg"\r\n

JPEG or IMAGE FILE HERE (in binary)

---webformkitXXXXXXXX\r\n END----

So when I am finally able to to memcpy together the different pieces I need, I can save it to file, and it looks just fine, but I can see from the packet captures, that CURL doesn't like taking the binary, it appears that it's truncating the buffer at the first sign of a '\0' because, it only sends like 300 bytes, when it should be sending 80K...

I've been using this: curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);

Thank You!


You need to use CURLOPT_WRITEDATA and plug in a function you have written to write the POST data.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜