有接触过这方面问题的人吗?

解决方案 »

  1.   

    方法很多的!兄弟。
    1.可以在 ActiveX中使用Socket 与相应的服务端通讯,由服务端负责保存数据到数据库中。
    2.可以使用DCOM。
    3.使用 COM+
    4.使用Web Service
      

  2.   

    CInternetSession m_Session("DigitalTitan");
        CHttpConnection* pServer=NULL;
        CHttpFile* pFile=NULL;
        CString strServerName=m_ServerName;
        INTERNET_PORT nPort=(INTERNET_PORT)atoi(m_ServerPort);
    CString strURL=m_DesignFile;
        try
        {

            pServer=m_Session.GetHttpConnection(strServerName,nPort);
    pFile=pServer->OpenRequest(CHttpConnection::HTTP_VERB_POST,strURL,NULL,1,NULL,NULL,INTERNET_FLAG_EXISTING_CONNECT);

    CString strBoundary="-----------------------------7d33a816d302b6";//分界线视CGI程序做响应改动.
            pFile->AddRequestHeaders("Content-Type: multipart/form-data, boundary="+strBoundary);
            pFile->AddRequestHeaders("Accept: **");

    char* pBuf=new char[1024*1000];

    //构造表单开始
    FieldStruct* pFieldStruct=new FieldStruct;
    POSITION CurrentPosition;

    for(int iIndex=0;iIndex<m_FieldData.GetCount();iIndex++)
    {
    CurrentPosition=m_FieldData.FindIndex(iIndex);
    pFieldStruct=(FieldStruct*)m_FieldData.GetAt(CurrentPosition); strcat(pBuf,(LPTSTR)(LPCTSTR)strBoundary); strcat(pBuf,"Content-Disposition: form-data;name=\"");
    strcat(pBuf,(LPTSTR)(LPCTSTR)pFieldStruct->m_FieldName);
    strcat(pBuf,"\"\r\n\r\n");
    strcat(pBuf,(LPTSTR)(LPCTSTR)pFieldStruct->m_FieldValue);
    strcat(pBuf,"\r\n");

    strcat(pBuf,(LPTSTR)(LPCTSTR)strBoundary);
    }
    //构造表单结束
    //
    CStdioFile m_File;
    BYTE pFileBuf[1024];
    CString strBuf;
    DWORD dwRead;
    strcat(pBuf,"Content-Disposition: form-data;name=\"FieldName\"\r\nfilename=\"FileName\"\r\n");
    if(m_File.Open(strTempDocPath,CFile::modeRead|CFile::typeBinary))
    {
    do
    {
    dwRead=m_File.Read(pFileBuf,1024);
    for(int kIndex=0;kIndex<(int)dwRead;kIndex++)
    {
    char strChar=*(char*)(pFileBuf+kIndex);
    if(strChar=='\0')
    {
    strBuf.Append("DigitalTitan",12);
    }
    else
    {
    strBuf.AppendChar(strChar);
    }

    //int iLastPosition=strlen(pBuf);
    //pBuf[iLastPosition]=strChar;
    //pBuf[iLastPosition+1]=0;
    }
    }
    while(dwRead>0);
    m_File.Close();
    }
    strcat(pBuf,(LPTSTR)(LPCTSTR)strBuf);
    strcat(pBuf,"\r\n");
    strcat(pBuf,(LPTSTR)(LPCTSTR)strBoundary);
    strcat(pBuf,"--");
    pFile->SendRequest(NULL,0,(LPVOID)pBuf,strlen(pBuf));

    pFile->Close();
    pServer->Close();
    //AfxMessageBox("UpLoad...",MB_ICONINFORMATION);
        }
        catch(CInternetException * e)
    {
    AfxMessageBox("...",MB_ICONINFORMATION);
    };
        delete pFile;
        delete pServer;
        m_Session.Close();
      

  3.   

    to gjd111686(数字金刚):
    你的程序应该是利用了HTTP协议吧,基本原理是不是通过构造一个类似HTML中的表单来把数据发送到服务器上去? 谢谢,很不错的做法,简单又实用,但假如我要利用Activex和HTTP协议来向服务器发送二进制文件呢?怎么用Activex利用服务器的文件上传功能?
      

  4.   

    你可以用web Service把二进制文件放在XML数据包中啊!
      

  5.   

    web Service?恩,准备研究一下这个东西了,不知道难不难