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
事件:OnCompleted(Sender: TObject; AStream: TFileStream)
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;