开发者

saving the file in the specified location using libcurl

I want to download a file from a URL using libcurl in C. I want to save the downloaded file into a specified location (i.e., /mnt/jffs2/ ) in my POS device.

I got code from some one and failed on executing that. Rather I can't save that file in my desired location.

So anyone help me please开发者_如何学运维.

Thanks in advance.


Most easily you use the default CURLOPT_WRITEFUNCTION (which calls fwrite) and just set CURLOPT_WRITEDATA to the FILE * of your target file:

FILE *body = fopen("/mnt/jffs2/storeit", "w");
...
curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, body);'
...
rc = curl_easy_perform(curl_handle);
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜