How can i download a file from a webserver, and save it in a specific path on Linux?
I have used this code (this is an expample):
CURL *curl;
FILE *fp;
CURLcode res;
const char *url = "http://google.com";
char outfilename[FILENAME_MAX] = "\\home\\user_name\\";
curl = curl_easy_init();
if (curl)
{
fp = fopen(outfilename,"wb");
curl_easy_setopt(curl, CURLOPT_URL, url);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, NULL);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
fclose(fp);
}
But it doesn't work perfectly, because it save the file with the absolute path in his name only in the working directory!
Can anyone help me with this problem? Thank you for your attention!