上传附件的实现

add_attachment(&URL_ID, &FILEEXTENSION, &SUBDIRECTORY, &FILESIZE, &PREPEND, &RECNAME, &ATTACHSYSFILENAME, &ATTACHUSERFILE, &MESSAGE_LVL, &RETCODE);

&ORIGSYSFILENAME = &ATTACHSYSFILENAME;       If &PREPEND And          None(&ORIGSYSFILENAME) Then       &uniquefilename = "";       &REC = GetRecord(@&RECNAME);       For &I = 1 To &REC.FieldCount          &Fld = &REC.getfield(&I);          If (&Fld.IsKey = True) Then             If (&Fld.value = "" And                   &Fld.IsRequired = True) Then                MessageBox(0, MsgGetText(137, 1, "File Attachment Status"), 137, 28, "Please attach the file after filling out the required fields on this page.");                Return;             Else                &uniquefilename = &uniquefilename | &Fld.value;             End-If;          End-If;       End-For;       &temp = Substitute(&uniquefilename, " ", ""); /* delete spaces */       &ATTACHSYSFILENAME = Left(&uniquefilename, 64); /* make uniq part a max of 64 chars */    End-If;       &ATTACHSYSFILENAME = &SUBDIRECTORY | &ATTACHSYSFILENAME;       &RETCODE = AddAttachment(&URL_ID, &ATTACHSYSFILENAME, &FILEEXTENSION, &ATTACHUSERFILE, &FILESIZE);       /* The actual name on the ftp file server is the following */    If &PREPEND Or          All(&ORIGSYSFILENAME) Then       &ATTACHSYSFILENAME = &ATTACHSYSFILENAME | &ATTACHUSERFILE;    Else       &ATTACHSYSFILENAME = &SUBDIRECTORY | &ATTACHUSERFILE;    End-If;    &temp = Substitute(&ATTACHSYSFILENAME, " ", ""); /* delete spaces */    &ATTACHSYSFILENAME = &temp;       If (&RETCODE = %Attachment_Success) Then       If &MESSAGE_LVL = 1 Then          MessageBox(0, MsgGetText(137, 1, "File Attachment Status"), 137, 27, "AddAttachment succeeded");       End-If;    Else       &ATTACHUSERFILE = "";       &ATTACHSYSFILENAME = "";    End-If;       If (&RETCODE = %Attachment_Cancelled) Then       If &MESSAGE_LVL = 1 Then          MessageBox(0, MsgGetText(137, 1, "File Attachment Status"), 137, 3, "AddAttachment cancelled");       End-If;    End-If;       If &MESSAGE_LVL = 1 Or          &MESSAGE_LVL = 2 Then       If (&RETCODE = %Attachment_Failed) Then          MessageBox(0, MsgGetText(137, 1, "File Attachment Status"), 137, 2, "AddAttachment failed");       End-If;             If (&RETCODE = %Attachment_FileTransferFailed) Then          MessageBox(0, MsgGetText(137, 1, "File Attachment Status"), 137, 4, "AddAttachment failed: File Transfer did not succeed");       End-If;       /* following error messsage only in iclient mode */       If (&RETCODE = %Attachment_NoDiskSpaceAppServ) Then          MessageBox(0, MsgGetText(137, 1, "File Attachment Status"), 137, 5, "AddAttachment failed: No disk space on the app server");       End-If;       /* following error messsage only in iclient mode */       If (&RETCODE = %Attachment_NoDiskSpaceWebServ) Then          MessageBox(0, MsgGetText(137, 1, "File Attachment Status"), 137, 6, "AddAttachment failed: No disk space on the web server");       End-If;       If (&RETCODE = %Attachment_FileExceedsMaxSize) Then          MessageBox(0, MsgGetText(137, 1, "File Attachment Status"), 137, 7, "AddAttachment failed: File exceeds the max size");       End-If;       If (&RETCODE = %Attachment_DestSystNotFound) Then          MessageBox(0, MsgGetText(137, 1, "File Attachment Status"), 137, 8, "AddAttachment failed: Cannot locate destination system for ftp");       End-If;       If (&RETCODE = %Attachment_DestSysFailedLogin) Then          MessageBox(0, MsgGetText(137, 1, "File Attachment Status"), 137, 9, "AddAttachment failed: Unable to login into destination system for ftp");       End-If;       If (&RETCODE = %Attachment_FileNotFound) Then          MessageBox(0, MsgGetText(137, 1, "File Attachment Status"), 137, 29, "The file was not found so the operation could not be completed.");       End-If;       /* Error Message for Invalid file or No file name */       If (&RETCODE = %Attachment_NoFileName) Then          MessageBox(0, MsgGetText(137, 1, "File Attachment Status"), 137, 38, "AddAttachment failed: No File Name Specified.");       End-If;          End-If;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值