uniGUI之上传文件UniFileUploadButton

2023-12-17 05:00:32

TUniFileUploadButton主要属性:

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

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

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

TUniFileUploadButton控件?支持多文件批量上传!?

procedure TMainForm.UniFileUploadButton1Completed(Sender: TObject;  AStream: TFileStream);
var
  i:integer;
begin
  UniFileUploadButton1.MultipleFiles:=True;//多选 模式  
  UniFileUploadButton1.MaxFiles:=4;         //最大文件数
         for I := 0 to UniFileUploadButton1.MaxFiles-1 do  begin
          caption:= UniFileUploadButton1.Files[i].FileName ;
         end;
end;

如果文件数超过MaxFiles

uniGUI之上传文件UniFileUploadButton(26)_uniGUI教程


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

uniGUI之上传文件UniFileUploadButton(26)_uniGUI学习_02

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;

文章来源:https://blog.csdn.net/delphigbg/article/details/135028604
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。