zl程序教程

您现在的位置是:首页 >  其他

当前栏目

VFP上传文件前判断文件大小,超过200M不让上传

2023-02-19 12:20:40 时间

代码很简单,以下是判断文件不能超过200M

cFile=Getfile("jpg|png")
If !File(lcFile)
  Return
Endif

ADIR(laarray,lcFile)

IF laarray[2]/1024>1024*200
  MESSAGEBOX("文件不能超过200M",0+16,thisform.Caption)
  RETURN 
ENDIF 

附HTTP文件上传代码(以后加上多线程上传功能)

lcUrl=Serverurl+"ctl_file.fsp?proc=upload"
oQiyuUpload=Newobject("QiyuUploadFile","QiyuUploadFile.prg")
cReturn=oQiyuUpload.uploadfile(lcUrl,lcFile)
If ISNULL(cReturn)
  Messagebox(oQiyuUpload.msg,0+16,Thisform.Caption)
  Return
Endif


oReturn=foxjson_parse(cReturn)
IF oReturn.item("errno")!=0
  MESSAGEBOX(oReturn.item("errmsg"),0+16,thisform.Caption)
  RETURN  
ENDIF 

?"文件名",oReturn.item("filename")