uniGUI之上传文件UniFileUploadButton

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;
相关推荐
看浪的路人1 天前
第3讲:代码补全引擎
开发语言·windows·python
小小龙学IT1 天前
Day 26-27 项目实战:从零构建一个高并发聊天室(epoll + 线程池)
linux·服务器·c语言·开发语言·网络
我就是妖怪1 天前
【无标题】
开发语言
0566461 天前
Python高级——迭代器
开发语言·python·学习
初级代码游戏1 天前
iOS开发 Swift 速记4:函数与闭包
开发语言·ios·swift
郭涤生1 天前
C++ 零拷贝(Zero-Copy)
linux·开发语言·c++
回忆2012初秋1 天前
C# 中的 EAP:基于事件的异步编程全面指南(一)
开发语言·c#
ty_xiumud1 天前
以太网 MAC 详解:帧格式、位序、FCS 与收发流程
开发语言·macos·php
曹牧1 天前
C#:Type
开发语言·c#
小僧景贤1 天前
嵌入式C语言 第十一篇:成长路线|嵌入式C工程师完整进阶学习路径(从零到工程级落地|含周期+实战项目)
c语言·开发语言·学习