Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ifstream file("C:\\image.jpg");
- file.seekg(0,ios::end);
- int size=file.tellg();
- file.seekg(0,ios::beg);
- file.clear();
- char cont[size];
- file.read(cont,size);
- string bodyReq="file=";
- for(int i=0;i<size;i++)
- {
- bodyReq.push_back(cont[i]);
- }
- bodyReq.append(cont);
- cout<<bodyReq.length()<<endl;
- sf::Http http;
- http.setHost("http://localhost/");
- sf::Http::Request request;
- request.setUri("images/index.php");
- request.setMethod(sf::Http::Request::Post);
- request.setField("Content-Type", "application/x-www-form-urlencoded");
- request.setBody(bodyReq);
- sf::Http::Response response=http.sendRequest(request);
- if(response.getStatus()==sf::Http::Response::Ok)
- {
- cout<<response.getBody();
- cin.get();
- }
- else
- {
- cout<<"error "<<response.getStatus()<<endl;
- cin.get();
- }
Advertisement
Add Comment
Please, Sign In to add comment