php - Upload text file using wininet in c++ -


i'm going upload text.txt file using wininet.
here code.

#include "stdafx.h" #include "iostream" #include "windows.h" #include "wininet.h" #include "tchar.h" #include "iostream" #include "string" #include "sstream"  #pragma comment(lib, "ws2_32.lib") #pragma comment(lib, "wininet.lib")  int main(){          tchar hdrs[] = _t("content-type: multipart/form-data; boundary=---------------------------7d82751e2bc0858"); tchar frmdata[] = _t("-----------------------------7d82751e2bc0858\r\ncontent-disposition: form-data; name=\"uploadedfile\"; filename=\"c:\\users\ahmer\desktop\asd\test.txt\"\r\ncontent-type: text/plain\r\n\r\nfile contents  here\r\n-----------------------------7d82751e2bc0858--\r\n"); lpctstr accept[] = {_t("*/*"), null};  hinternet hsession = internetopen(_t("myagent"), internet_open_type_preconfig, null, null, 0); hinternet hconnect = internetconnect(hsession, _t("http://localhost/cpp/"), internet_default_http_port, null, null, internet_service_http, 0, 1); hinternet hrequest = httpopenrequest(hconnect, _t("post"), _t("uploadfile.php"), null, null, accept, 0, 1); bool sent = httpsendrequest(hrequest, hdrs, _tcslen(hdrs), frmdata, _tcslen(frmdata));      if(hsession==null) {  cout<<"error: internetopen";   } if(hconnect==null) {  cout<<"error: internetconnect";   } if(hrequest==null) {  cout<<"error: httpopenrequest";   } if(!sent) {  cout<<"error: httpsendrequest";  }   //close valid internet-handles    internetclosehandle(hsession);    internetclosehandle(hconnect);    internetclosehandle(hrequest);     return 0;      } 

here php file.

move_uploaded_file($_files["uploadedfile"]["tmp_name"], "/filefolder"); 

there error error: httpopenrequest. problem code. read question here in question user did not paste code rather give link of website closed not helpfull now.
dev c++ wininet upload file using http

but find php code there.


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -