I would like to send a text file to a web server using wininet, as if the file was submitted using a web form that sends the file to the server.
Based on the answers I received, I tried the following code:
static TCHAR hdrs[] = "Content-Type: multipart/form-data\nContent-Length: 25"; static TCHAR frmdata[] = "file=filename.txt\ncontent"; HINTERNET hSession = InternetOpen("MyAgent", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0); HINTERNET hConnect = InternetConnect(hSession, "example.com", INTERNET_DEFAULT_HTTP_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 1); HINTERNET hRequest = HttpOpenRequest(hConnect, "POST", "test.php", NULL, NULL, NULL, 0, 1); HttpSendRequest(hRequest, hdrs, strlen(hdrs), frmdata, strlen(frmdata));");
The test.php script is executed, but it does not seem to receive the correct data.
Can someone give me extra help or take a look somewhere? Thanks.
source share