RT:
   在C/S结构中,打算把C端的文件等上传到S;同样C端也可以从S端下载需要的文件,如何做到呢,求教高人指点迷津.........

解决方案 »

  1.   

    1,把文件存入数据库中
    2,用indy的组件
      

  2.   

    我的做法:将文件分解成字符串存入数据库(当时是FREESBD+MYSQL)
    //将文件分解读入LST
      with flStream do
      begin
        iSumReadCount := 0;
        while iSumReadCount < size do
        begin
          iReadSize := size - iSumReadCount;  // 需要读入字节 = 文件大小 - 已读字节
          if iReadSize > FIniInf.MaxFileSize then     //如果需要读入字节大于缓冲长度
            iReadSize := FIniInf.MaxFileSize;         //则读入缓冲长度数量的字节
          s := '';
          setlength(s, iReadSize);
          Read(pointer(@s[1])^, iReadSize);   //将读入的字节保存到LST
          lst.Add(s);
          iSumReadCount := iSumReadCount + iReadSize; //已读字节
          Application.ProcessMessages;
        end;
      end;
    //遍历LST将字符串写入数据库
      //下载过程

    //下载字符串
    while not eof do
        begin
          s := s + FieldByName('ZCONTENT').AsString;
          Next;
          Application.ProcessMessages;
        end;

    //将字符串保存为文件
    if s <> '' then
      try
        FileHandle := FileCreate(sFileName);
        FileWrite(FileHandle, s[1], length(s));
        FileClose(FileHandle);
        WriteMm(format('下载成功:%s。',[sFileName]));
      except
        on e:exception do
          begin
            WriteMm(format('%s下载失败;Error:%s。', [sFileName, e.Message]));
          end;
      end;

      

  3.   

    方法不少....CSDN里原来见过这样的贴,楼主找找吧....
      

  4.   

    http://blog.csdn.net/jinzhili/archive/2004/11/05/168220.aspx
      

  5.   

    INDY的IDTCPCLIENT 和IDTCPSERVER这两个最好 ,可以实现多线程的多点对一点的传输  当然FTP也可以实现同样的功能把文件存入数据库也可以,速度要慢点 安全性好