TUniFileUploadButton主要属性:
Filter: 文件类型过滤,有图片image/* audio/* video/*三种过滤
MaxAllowedSize: 设置文件最大上传尺寸;
Message:标题以及消息文本,可翻译成中文
TUniFileUploadButton控件 支持多文件批量上传!
procedure TMainForm.UniFileUploadButton1Completed(Sender: TObject; AStream: TFileStream); vari:integer; beginUniFileUploadButton1.MultipleFiles:=True;//多选 模式 UniFileUploadButton1.MaxFiles:=4; //最大文件数for I := 0 to UniFileUploadButton1.MaxFiles-1 do begincaption:= UniFileUploadButton1.Files[i].FileName ;end; end;
如果文件数超过MaxFiles
事件:OnCompleted(Sender: TObject; AStream: TFileStream)
procedure TMainForm.UniFileUploadButton1Completed(Sender: TObject; AStream: TFileStream); varDestName : 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;