unit IWUnit1; {PUBDIST} interface uses IWAppForm, IWApplication, IWTypes, IWCompButton, Classes, Controls, IWControl, IWCompListbox, IWCompEdit, IWHTMLControls, IWCompLabel, Forms, IWContainer, IWRegion, IWGrids; type TformUpDown = class(TIWAppForm) IWHRule1: TIWHRule; IWRegion1: TIWRegion; IWButton1: TIWButton; lboxFiles: TIWListbox; IWRegion2: TIWRegion; IWFile1: TIWFile; IWButton2: TIWButton; lablFileInfo: TIWLabel; procedure IWAppFormCreate(Sender: TObject); procedure IWButton1Click(Sender: TObject); procedure IWButton2Click(Sender: TObject); public FPath: string; end; implementation {$R *.dfm} uses SysUtils, SWSystem; procedure TformUpDown.IWAppFormCreate(Sender: TObject); var i: Integer; LSrch: TSearchRec; begin lboxFiles.Items.Clear ; FPath := gsAppPath + 'Downloads/'; i := FindFirst(FPath + '*.*', faAnyFile, LSrch); try while i = 0 do begin if (LSrch.Attr and faDirectory) = 0 then lboxFiles.Items.Add(LSrch.Name); i := FindNext(LSrch); end; finally FindClose(LSrch); end; lboxFiles.ItemIndex := 0; end; procedure TformUpDown.IWButton1Click(Sender: TObject); begin if lboxFiles.ItemIndex > -1 then begin WebApplication.SendFile(FPath + lboxFiles.Text, '', '', true); end; end; procedure TformUpDown.IWButton2Click(Sender: TObject); begin IWFIle1.SaveToFile(ExtractFilePath(ParamStr(0))+ 'Downloads/' + IWFile1.FileName); lablFileInfo.Caption := IWFile1.Filename +' 上传成功! ' + #13#10 + '文件已经成功保存到: ' + ExtractFilePath(ParamStr(0))+ 'Downloads/'; lablFileInfo.Visible := True; IWAppFormCreate(nil); end; end.
实现文件的下载上传
最新推荐文章于 2023-11-30 18:26:31 发布