RT

解决方案 »

  1.   

    post数据,boundary随即生成Content-type: multipart/form-data, boundary=AaB03x --AaB03x 
    content-disposition: form-data; name="user" Wilson Peng 
    --AaB03x 
    content-disposition: form-data; name="myfile" 
    Content-type: multipart/mixed, boundary=BbC04y --BbC04y 
    Content-disposition: attachment; filename="myphoto.gif" 
    Content-type: image/gif 
    Content-Transfer-Encoding: binary ...myphoto.gif 内容略... 
    --BbC04y-- 
    --AaB03x--
      

  2.   

    http://search.csdn.net/Expert/topic/1084/1084909.xml?temp=.3063318
      

  3.   

    void CProject1Dlg::OnOK(void)
    {
    CString m_sServer;
    CString m_sPath;
    UpdateData(true);
    if(m_sUrl.IsEmpty())
    return;
    CString stmp;
    stmp=m_sUrl;
    //m_sUrl is a edit box to input URL;
    //you can use http://www.csdn.net/expert/topic/55011.shtm or 
    //http://www.aaa.com/test.asp?id=xxx
    stmp.MakeUpper();
    if(stmp.Left(7)!="HTTP://")
    {
    AfxMessageBox("wrong url header");
    return ;
    }
    else
    stmp=m_sUrl.Mid(7);
    int nSlashPos=stmp.Find("/");
    if(nSlashPos!=-1)
    {
    m_sServer=stmp.Left(nSlashPos);
    m_sPath=stmp.Mid(nSlashPos);
    stmp= m_sServer+"       \n"+m_sPath;
    AfxMessageBox(stmp);
    }
    else
    {
    AfxMessageBox("/ not find");
    return;
    }
    HINTERNET hSession=::InternetOpen("raw html reader",PRE_CONFIG_INTERNET_ACCESS,"",INTERNET_INVALID_PORT_NUMBER,0);
    if(hSession==NULL)
    {
    AfxMessageBox("Internetopen failed");
    return;
    }
    HINTERNET hConnect=::InternetConnect(hSession,m_sServer,INTERNET_INVALID_PORT_NUMBER,"","",INTERNET_SERVICE_HTTP,0,0);
    if(hConnect==NULL)
    {
    AfxMessageBox("InternetConnect failed");
    ::InternetCloseHandle(hSession);
    return;
    }
    HINTERNET hHttpFile=::HttpOpenRequest(hConnect,"GET",m_sPath,HTTP_VERSION,NULL,0,INTERNET_FLAG_DONT_CACHE,0);
    if(hHttpFile==NULL)
    {
    AfxMessageBox("can not call HttpOpenRequest");
    ::InternetCloseHandle(hConnect);
    ::InternetCloseHandle(hSession);
    return;
    }
    CWaitCursor wait;
    BOOL bSend=::HttpSendRequest(hHttpFile,NULL,0,0,0);
    if(bSend)
    {
    char cQueryBuf[16];
    DWORD dwFileSize;
    DWORD dwQueryBufLen=sizeof(cQueryBuf);
    BOOL bQuery=::HttpQueryInfo(hHttpFile,HTTP_QUERY_CONTENT_LENGTH,cQueryBuf,&dwQueryBufLen,NULL);
    if(bQuery)
    {
    dwFileSize=(DWORD)atol(cQueryBuf);
    }
    else
    dwFileSize=10*1024;
    char *lpszBuf=new char[dwFileSize+1];
    DWORD dwBytesRead;
    BOOL bRead=::InternetReadFile(hHttpFile,lpszBuf,dwFileSize+1,&dwBytesRead);
    m_sContent=(LPCTSTR)lpszBuf;
    delete lpszBuf;
    }
    UpdateData(false);}
      

  4.   

    谢谢大家的回复!!!vcmute(横秋):可以给一个例子吗?xuzheng318(forever C++)(忧郁王子):我需要上传文件,而不是POST一个http请求这么简单。在服务器端,有一个页面负责接收。请高手多多帮忙!!
      

  5.   

    Q177188  Using HttpSendRequestEx for Large POST Requests
      

  6.   

    rfc1867,有关http form的详细说明
    接收到的数据,注意要判断是否为chunk编码
      

  7.   

    利用HTTP方式上传http://www.xiaozhou.net/cooldog/blogview.asp?logID=57
      

  8.   

    我的BLOG收录了一篇文章。看上面的链接。。
      

  9.   

    kugou123(酷狗):编译你在blog提供的代码,出现下列问题:nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __endthreadex
    nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __beginthreadex
      

  10.   

    #include <process.h>  试试
      

  11.   

    kugou123(酷狗):
    正解,我刚刚试过,把#include <process.h>加上后就没问题了