m_dwHttpRequestFlags= INTERNET_FLAG_EXISTING_CONNECT | INTERNET_FLAG_NO_AUTO_REDIRECT; CHttpFile *pFile =m_pHttp->OpenRequest(CHttpConnection::HTTP_VERB_PUT ,
strFile, NULL, 1, NULL, NULL, m_dwHttpRequestFlags);  CString strFilea;
strFilea = strFile;
try
{
pFile->SendRequest(); 
}
catch(CInternetException* pEx)
{
TCHAR szError[1024];
pEx->GetErrorMessage(szError,1024);
AfxMessageBox(szError);
pFile->Close();
return FALSE;
}
char buf[MAXSIZE];
DWORD dwRead=0;
UINT nBytesRead=1;         DWORD dwWritten;
BOOL bRet;
strcpy(buf,"Hello,World");         bRet = InternetWriteFile(pFile,buf,5, &dwWritten);//不报错,但是写不到到文件中
         //pFile->Write(buf,nBytesRead);   //这句直接报错.      
if(!bRet)
{
memset(buf,0,MAXSIZE);
         //bRet = InternetGetLastResponseInfo( &lRet,buf,&lBuffLen);
    nRet = GetLastError();
}
}
pFile->Close();
return FALSE;

解决方案 »

  1.   

    InternetWriteFile的pFile应该是:
    Valid HINTERNET handle returned from a previous call to FtpOpenFile or an HINTERNET handle sent by HttpSendRequestEx.
      

  2.   

    pFile->SendRequestEx(5);pFile->WriteString(strData);   
    pFile->EndRequest();
      

  3.   

    CString strData = “Some very long data to be POSTed here!”;
    pServer = sess.GetHttpConnection("mooseboy");
    pFile = pServer->OpenRequest(CHttpConnection::HTTP_VERB_POST, "/isapi.dll?");
    pFile->SendRequestEx(strData.GetLength());pFile->WriteString(strData);   
    pFile->EndRequest();
      

  4.   

    但是,如何控制上传权限啊? IIS 和 tomcat之间有什么区别需要考虑吗?
    还是只需要用登陆用户密码控制?m_pHttp=m_cis.GetHttpConnection(m_strServer,m_dwPort,"appuser","apppwd");
      

  5.   

    用WinInet实现,楼主看看这个例子http://support.microsoft.com/kb/177188/EN-US/