起步软件技术论坛-X3

 找回密码
 立即注册
搜索
12
返回列表 发新帖
楼主: zykj

上传附件功能**

[复制链接]
 楼主| 发表于 2009-7-10 15:26:27 | 显示全部楼层
即使开通FTP服务器,也没办法做到所有用户都能访问,网络上很多防火墙都卡住了

有没有什么其它方法,可以实现客户端上传文件,保存到服务器
就像论坛这样通过http上传文件
回复 支持 反对

使用道具 举报

发表于 2009-7-10 15:56:24 | 显示全部楼层
那就是用我们的文档服务器把附件上传到应用服务器上:具体代码参考下面:


【代码实现文件的上传、下载、打开】

引用【业务模型\协同系统\文档\文档库】
1、打开
procedure TFRMDOCCENTER.OpenClick(Sender: TObject);
var
  lResult: String;
begin
  if not isFile then exit;
  try
    lResult := TUnStructureDocUtils.OpenFile(Context, FileName, TDocAccessKind.akReadOut);
  except
    lResult := TUnStructureDocUtils.OpenFile(Context, FileName, TDocAccessKind.akReadOut);
  end;
  jsDialogs.ShowMsg(lResult, 'OpenFile:');
end;
{
function TFRMDOCCENTER.isFile: Boolean;
begin
  result := datasetdsWDs.FieldByName('FISDIRECTORY').AsString = 'N';
end;

//filename = getfilename
function TFRMDOCCENTER.GetFileName: String;
begin
  with DataSetdsWDS do
    begin
      if not Active then Open;
      if (RecordCount > 0) then
        result := DataSetdsWDS.FieldByName('Path').AsString
      else result := '';
    end;
end;

procedure TFRMDOCCENTER.CheckInClick(Sender: TObject);
begin
  if not isFile then exit;
  TDocSystem.CheckIn(Context, FileName);
end;
}

2、上传
procedure TFRMDOCCENTER.UpLoadClick(Sender: TObject);
var
  lFileName, osFile, lExt: string;
  lFileAttribute: TFileAttribute;
begin
  if (edit1.Text = '') or (edit2.Text = '') or (edit3.Text = '') then
    begin
      jsDialogs.ShowMsg('请选择上文件和存储路径!', '提示:');
      exit;
    end;
  lFileAttribute := TFileAttribute.Create;
  try
    lFileAttribute.DisplayName := edit1.Text;
    lFileAttribute.Size := 0;
    lFileAttribute.CreateTime := SysUtils.Now;
    lFileAttribute.IsDirectory := false;
    lFileAttribute.IsHidden := false;
    lFileAttribute.IsSpace := false;
    lFileAttribute.LastWriteTime := SysUtils.Now;
    lFileAttribute.ValuesAsString['OSFILENAME'] := edit3.Text;

    lExt := Sysutils.ExtractFileExt(edit1.Text);
    lFileName := edit2.text + jsCommon.CreateGUIDStr + lExt;
    osFile := TUnStructureDocUtils.NewFile(Context, lFileName, lFileAttribute);
    //TDocSystem.CheckIn(Context, lFileName);
  finally
    lFileAttribute.Free;
    jsDialogs.ShowMsg(osFile, 'UpLoad:');
  end;
end;

3、下载
procedure TFRMDOCCENTER.DownLoadClick(Sender: TObject);
begin
  if not isFile then exit;
  if SaveDialog1.Execute then
    TUnStructureDocUtils.DownLoadFile(FileName, SaveDialog1.FileName);
end;


4、选择文档路径
procedure TFRMDOCCENTER.Button2Click(Sender: TObject);
begin
  edit2.text := 'Doc:' + TSelectDocPath.getDocPath(Context);
end;
回复 支持 反对

使用道具 举报

发表于 2010-6-24 15:46:55 | 显示全部楼层
TUnStructureDocUtils,需要引用那个单元?
回复 支持 反对

使用道具 举报

发表于 2010-6-24 15:53:47 | 显示全部楼层
12楼有说:引用【业务模型\协同系统\文档\文档库】
回复 支持 反对

使用道具 举报

发表于 2010-6-24 16:20:37 | 显示全部楼层
好使了,打开“文档库”提示,对象"Biz:\COLLABORATION\DOC\DOCLIB.LIBRARY"没有语言信息,不能生成代码文件,还以为不能用呢。
文档库没有代码文件?
回复 支持 反对

使用道具 举报

发表于 2010-6-24 17:13:58 | 显示全部楼层
对,文档库代码没有对外开放。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Justep Inc.

GMT+8, 2025-7-8 15:39 , Processed in 0.038639 second(s), 12 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表