Guest User

Untitled

a guest
May 5th, 2013
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     ifstream file("C:\\image.jpg");
  2.  
  3.     file.seekg(0,ios::end);
  4.     int size=file.tellg();
  5.     file.seekg(0,ios::beg);
  6.     file.clear();
  7.     char cont[size];
  8.     file.read(cont,size);
  9.     string bodyReq="file=";
  10.  
  11.     for(int i=0;i<size;i++)
  12.     {
  13.         bodyReq.push_back(cont[i]);
  14.     }
  15.     bodyReq.append(cont);
  16.     cout<<bodyReq.length()<<endl;
  17.  
  18.     sf::Http http;
  19.     http.setHost("http://localhost/");
  20.     sf::Http::Request request;
  21.     request.setUri("images/index.php");
  22.     request.setMethod(sf::Http::Request::Post);
  23.     request.setField("Content-Type", "application/x-www-form-urlencoded");
  24.     request.setBody(bodyReq);
  25.     sf::Http::Response response=http.sendRequest(request);
  26.     if(response.getStatus()==sf::Http::Response::Ok)
  27.     {
  28.         cout<<response.getBody();
  29.         cin.get();
  30.     }
  31.     else
  32.     {
  33.         cout<<"error "<<response.getStatus()<<endl;
  34.         cin.get();
  35.     }
Advertisement
Add Comment
Please, Sign In to add comment