Guest User

Untitled

a guest
Apr 26th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. struct curl_slist *headerlist = NULL;
  2. const char * Picture = "C:xxxx";
  3.  
  4. FILE *fd = fopen(Picture, "rb");
  5. struct stat file_info;
  6. fstat(fileno(fd), &file_info);
  7.  
  8. headerlist = curl_slist_append(headerlist, "user : xxxx");
  9. headerlist = curl_slist_append(headerlist, "password : xxxxx");
  10. headerlist = curl_slist_append(headerlist, "Content-Type: image/jpeg");
  11.  
  12.  
  13. curl = curl_easy_init();
  14.  
  15. curl_easy_setopt(curl, CURLOPT_URL, "http://xxxx.000webhostapp.com/Pictures");
  16. curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerlist);
  17. curl_easy_setopt(curl, CURLOPT_POST, 1L);
  18. curl_easy_setopt(curl, CURLOPT_READDATA, fd);
  19. curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (curl_off_t)file_info.st_size);
  20.  
  21. res = curl_easy_perform(curl);
  22.  
  23. if (res != CURLE_OK)
  24. {
  25.  
  26. MessageBox::Show("Picture Failed");
  27.  
  28. }
  29.  
  30.  
  31. curl_easy_cleanup(curl);
  32.  
  33. curl_global_cleanup();
Add Comment
Please, Sign In to add comment