uniGUI之上传文件UniFileUploadButton(26)

TUniFileUploadButton主要属性:

Filter: 文件类型过滤,有图片image/*   audio/* video/*三种过滤

MaxAllowedSize: 设置文件最大上传尺寸;

Message标题以及消息文本,可翻译成中文

TUniFileUploadButton控件目前最大的问题是不支持文件批量上传! 

事件:OnCompleted(Sender: TObject; AStream: TFileStream)

uniGUI之上传文件UniFileUploadButton(26)_第1张图片

procedure TMainForm.UniFileUploadButton1Completed(Sender: TObject;  AStream: TFileStream);
var
  DestName : string;
  DestFolder : string;
begin
  //将 文件 加载到  UniImage1里
    UniImage1.Picture.LoadFromFile(AStream.FileName);
    Caption:='File Name: '+UniFileUploadButton1.FileName;

//将 文件 保存到UploadFolder文件夹,先要创建这个UploadFolder文件夹
    DestFolder:=UniServerModule.StartPath+'UploadFolder\';   //要在与exe同下新建一个UploadFolder文件夹
    DestName:=DestFolder+ExtractFileName(UniFileUploadButton1.FileName);
    CopyFile(PChar(AStream.FileName), PChar(DestName), False);
    ShowMessage('File: '+UniFileUploadButton1.FileName+' Uploaded to folder: '+DestFolder);

end;

 

你可能感兴趣的:(uniGUI之上传文件UniFileUploadButton(26))