Hi,
I have problems with below code:
HINTERNET Initialize = InternetOpen(0, INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
HINTERNET hConnect = InternetConnect(Initialize, server, 80, user, pass, INTERNET_SERVICE_HTTP, 0, 0);
FtpSetCurrentDirectoryW(hConnect, path);
HINTERNET hReq = HttpOpenRequest(hConnect, L"POST", r1, NULL, NULL, NULL, INTERNET_FLAG_KEEP_CONNECTION &&
INTERNET_FLAG_NO_CACHE_WRITE, 0);
HANDLE hFile = CreateFile(upFile, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if(hFile == INVALID_HANDLE_VALUE)
{
printf("\nFailed to open local file %s.", upFile);
return FALSE;
}
BOOL bRead;
BOOL bRead1;
BYTE pBuffer[1024];
BYTE pBuffer1[1024];
DWORD dwBytesRead;
BOOL bRet;
bool result;
DWORD dwBytesWritten;
if(HttpSendRequestEx(hReq, NULL, 0, NULL,0))
{
DWORD sum = 0;
do
{
if(!(bRead = ReadFile(hFile, pBuffer, sizeof(pBuffer), &dwBytesRead, NULL)))
{
printf("\nReadFile failed on buffer %lu.", GetLastError());
result = FALSE;
break;
}
if(!(bRet=InternetWriteFile(hReq, pBuffer, dwBytesRead, &dwBytesWritten)))
{
printf("\nInternetWriteFile failed %lu", GetLastError());
if (GetLastError() == 12019)
{
cout << "\nERROR_INTERNET_INCORRECT_HANDLE_STATE\n" << endl;
}
result = FALSE;
break;
}
sum += dwBytesWritten;
}
while(dwBytesRead == sizeof(pBuffer));
CloseHandle(hFile);
printf("\nActual written bytes: %d\n", sum);
}
InternetCloseHandle(hReq);
InternetCloseHandle(hConnect);
InternetCloseHandle(Initialize);
It runs and not shows any errors.
But my problem is that not make any file and write on that in my server.
Other my problem is how define path in my code?
for example my file is in www.www.com/reza
how make that read my file in "reza" folder(path).
Regards,