I would like to transfer a text file to a webserver using wininet as if the file was being transferred using a web form that posts the file to the server.
Based on answers I've received I've 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 being run, but it doesn't appear to be getting the correct data.
Could anyone give me any additional help or somewhere to look? Thanks.