TUniFileUploadButton主要属性:

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

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:='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/dlboy2018/article/details/105284722

 

procedure TMainForm.UniFileUpload1Completed(Sender: TObject;  AStream: TFileStream);
begin
  // 上传图片
  var
    DestFolder: string := UniServerModule.StartPath + 'UploadFolder\';
  var
    aFile: string := Format('%d_%d_%d_%d', [YearOf(Now), MonthOf(Now),
      DayOf(Now), GetTickCount64]);
  var
    DestName: string := DestFolder + aFile +
      ExtractFileName(UniFileUpload1.FileName);
  CopyFile(PChar(AStream.FileName), PChar(DestName), False);
  var
    AHtml: string := '/UploadFolder/' + aFile +
      ExtractFileName(UniFileUpload1.FileName);
  var
    js: string := 'insertHtml("img","' + AHtml + '","' +
      ExtractFileName(UniFileUpload1.FileName) + '");';
  UniSession.AddJS(js);
end;

uniFileUpload1窗口Width

 

uniFileUpload1窗口Height设置,应该在uniFileUpload.pas里面修改

function TUniFileUpload._Execute(Blocking: Boolean): Boolean;
var
  FButton : TUniButton;
  FCButton : TUniButton;
  FMemo : TUniMemo;
  FJSFileUpload : TJSControl;
  FUploadForm: TUniForm;
  N : Integer;
  S : string;
begin
  AdjustServerParams;

  Canceled := False;
  FUploadForm := TUniForm.Create(UniApplication);
  FUploadForm.Position := poScreenCenter;

  FUploadForm.Width := FWidth;
  if FButtonOnly then
    FUploadForm.Height := 75 + UniSession.CurrentTheme.BandHeight
  else
    FUploadForm.Height := 104 + UniSession.CurrentTheme.BandHeight; 

 总是说我字少! 总是说我字少!总是说我字少! 总是说我字少!