updating log entry server scripts
This commit is contained in:
@@ -164,4 +164,35 @@ char* url_encode(const char* input) {
|
||||
|
||||
return encoded;
|
||||
}
|
||||
|
||||
int upload_to_srv(const char* url, const char* filepath,bool ignore_insecure) {
|
||||
//upload a file to the server
|
||||
CURL* curl;
|
||||
CURLcode res;
|
||||
struct curl_httppost* formpost = NULL;
|
||||
struct curl_httppost* lastptr = NULL;
|
||||
struct curl_slist* headerlist = NULL;
|
||||
static const char buf[] = "Expect:";
|
||||
curl_global_init(CURL_GLOBAL_ALL);
|
||||
curl_formadd(&formpost, &lastptr, CURLFORM_COPYNAME, "file", CURLFORM_FILE, filepath, CURLFORM_END);
|
||||
curl = curl_easy_init();
|
||||
if (curl) {
|
||||
curl_easy_setopt(curl, CURLOPT_URL, url);
|
||||
if(ignore_insecure==true)
|
||||
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
|
||||
headerlist = curl_slist_append(headerlist, buf);
|
||||
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerlist);
|
||||
curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost);
|
||||
res = curl_easy_perform(curl);
|
||||
curl_easy_cleanup(curl);
|
||||
curl_formfree(formpost);
|
||||
curl_slist_free_all(headerlist);
|
||||
if (res == CURLE_OK) {
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user