愛招飛幫助手冊 愛招飛幫助手冊
  • FastERP-1
  • Smart
  • PinToo
  • FastWeb
  • FastERP-2 企業管理系統 (opens new window)
  • 印染業ERP (opens new window)
  • 工廠終端機 (opens new window)
  • TARS
  • MARS
  • TaskRunner
  • Flying
  • FastDesk
  • HiDesk
  • HiNAT
  • FastBPM
  • 設備故障診斷 (opens new window)
  • 設備最佳運轉效益 (opens new window)
  • 企業智能助手SmeGPT (opens new window)
  • 燈號管理 (opens new window)
  • 戰情室 (opens new window)
  • 能源管理 (opens new window)
  • 人車定位 (opens new window)
  • 戰情指揮系統 (opens new window)
  • FastERP-1
  • FastWeb
  • Smart
  • PinToo
  • Flying
  • TARS
  • 通用功能

    • Report
    • Script
    • Echarts
    • Chart
    • DB Install
  • FastERP-1
  • Smart
  • PinToo
  • FastWeb
  • FastERP-2 企業管理系統 (opens new window)
  • 印染業ERP (opens new window)
  • 工廠終端機 (opens new window)
  • TARS
  • MARS
  • TaskRunner
  • Flying
  • FastDesk
  • HiDesk
  • HiNAT
  • FastBPM
  • 設備故障診斷 (opens new window)
  • 設備最佳運轉效益 (opens new window)
  • 企業智能助手SmeGPT (opens new window)
  • 燈號管理 (opens new window)
  • 戰情室 (opens new window)
  • 能源管理 (opens new window)
  • 人車定位 (opens new window)
  • 戰情指揮系統 (opens new window)
  • FastERP-1
  • FastWeb
  • Smart
  • PinToo
  • Flying
  • TARS
  • 通用功能

    • Report
    • Script
    • Echarts
    • Chart
    • DB Install
  • FastWeb幫助主頁
  • 學習手冊

  • 開發手冊

    • 通訊協議

      • 通訊埠

      • ModbusTCP

      • MQTT

      • RestAPI

      • HTTP

        • 簡訊發送(WEB)
        • 電子郵件(WEB)
        • FTP文件管理(WEB)
          • 1. 說明
          • 2. 設計明細
          • 3. 程式設計
            • 3.1. 程式初始設定
            • 3.2. 事件設定
          • 4. 運行結果
        • 郵件發送-控制元件(WEB)
    • 互動輸出

    • 媒體存取

    • 人工智慧

    • 實體運用

目录

FTP文件管理(WEB)

# FastWeb之FTP文件管理

  • 適用平臺:WEB(桌面)

# 1. 說明

  該範例可實現檔案的上傳與下載功能。支援FTP的上傳方式。

  通過本範例學習,可以掌握檔案上傳以及檔案下載的方式。

# 2. 設計明細

  開啟FastWeb設計器,分別加入下插圖之控制元件。或者點選左上角的[匯入]選擇模板檔案來打開對應模板。

  ①:TUgEdit元件,控制元件名稱為UgEdit01。

  ②:TUgEdit元件,控制元件名稱為UgEdit03。

  ③:TUgEdit元件,控制元件名稱為UgEdit04。

  ④:TUgEdit元件,控制元件名稱為UgEdit02。

  ⑤:TUgEdit元件,控制元件名稱為UgEdit05。

  ⑥:TUgButton元件,控制元件名稱為UgButton01。

  ⑦:TUgButton元件,控制元件名稱為UgButton02。

  ⑧:TUgFileUploadButton元件,控制元件名稱為UgFileUploadButton01。

  • UgWebRunFrame屬性設定

    • Height:設定頁面高度=234。
    • Width:設定頁面寬度=567。
  • ①UgEdit01屬性設定

    • FieldLabel:設定欄位標籤文字內容=FTP使用者名稱。
    • FieldLabelAlign:設定欄位標籤在編輯框的相對位置,設定為laTop。
  • ②UgEdit03屬性設定

    • FieldLabel:設定欄位標籤文字內容=FTP地址。
    • FieldLabelAlign:設定欄位標籤在編輯框的相對位置,設定為laTop。
  • ③UgEdit04屬性設定

    • FieldLabel:設定欄位標籤文字內容=檔案。
    • FieldLabelAlign:設定欄位標籤在編輯框的相對位置,設定為laTop。
  • ④UgEdit02屬性設定

    • FieldLabel:設定欄位標籤文字內容=FTP密碼。
    • FieldLabelAlign:設定欄位標籤在編輯框的相對位置,設定為laTop。
  • ⑤UgEdit05屬性設定

    • FieldLabel:設定欄位標籤文字內容=埠號。
    • FieldLabelAlign:設定欄位標籤在編輯框的相對位置,設定為laTop。
  • ⑥UgButton01屬性設定

    • Caption:設定按鈕顯示的字幕=上傳檔案。
  • ⑦UgButton02屬性設定

    • Caption:設定按鈕顯示的字幕=下載檔案。
  • ⑧UgFileUploadButton01屬性設定

    • Caption:設定按鈕顯示的字幕=選擇檔案。

# 3. 程式設計

# 3.1. 程式初始設定

  該程式無程式初始設定。

# 3.2. 事件設定

  • ⑥UgButton01-OnClick事件

  點選[上傳檔案]按鈕以執行FTP上傳檔案。

    //JScript
    function UgButton01OnClick(sender)
    {
      if (UgEdit04.Text == "") {
        Showmessage(UGMM.LT("檔案不能為空"));
        exit;
      }
      var Param = new TStringlist();
      Try{
        Param.Values["host"] =  ugedit03.Text;
        Param.Values["port"] =  ugedit05.Text;
        Param.Values["uc"] = ugedit01.Text;
        Param.Values["pwd"] = ugedit02.Text;
        Param.Values["dir"] = "";
        Param.Values["sourcefile"] = UgEdit04.Text;
        Param.Values["destfile"] = "";
        if (FTPUpFile(Param)){
          ShowMessage(UGMM.LT("檔案上傳成功!"));
        }
        else{
          ShowMessage(UGMM.LT("檔案上傳失敗!"));
        }
      }
      Finally{
        FreeAndNil(Param);
      }
    }
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    //PasScript
    procedure UgButton01OnClick(sender: tobject);
    var
      Param: TStringlist;
    begin
      if UgEdit04.Text = '' then 
      Begin
        Showmessage('檔案不能為空');
        exit;
      end;
      Param := TStringlist.Create;
      Try
        Param.Values['host'] :=  ugedit03.Text;
        Param.Values['port'] :=  ugedit05.Text;
        Param.Values['uc'] := ugedit01.Text;
        Param.Values['pwd'] := ugedit02.Text;
        Param.Values['dir'] := '';
        Param.Values['sourcefile'] := UgEdit04.Text;
        Param.Values['destfile'] := '';
        if FTPUpFile(Param) then
          ShowMessage('檔案上傳成功!')
        else
          ShowMessage('檔案上傳失敗!');
      Finally
        FreeAndNil(Param);
      End;
    end;
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    // Make sure to add code blocks to your code group
    • ⑦UgButton02-OnClick事件

      點選[下載檔案]以執行檔案的下載。

      //JScript
      function UgButton02OnClick(sender)
      //下載檔案
      {
        if (UgEdit04.Text == "")
        {
          Showmessage(UGMM.LT("地址為空,請先上傳檔案后再進行下載!"));
          return;
        }
        Unisession.SendFile(UgEdit04.Text,UgFileUploadButton01.FileName);
      }
      
      1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      11
      //PasScript
      procedure UgButton02OnClick(sender: tobject);
      //下載檔案
      begin
        if UgEdit04.Text = '' then
        Begin
          Showmessage(UGMM.LT('地址為空,請先上傳檔案后再進行下載!'));
          Exit;
        End;
        Unisession.SendFile(UgEdit04.Text,UgFileUploadButton01.FileName);
      end;
      
      1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      11
      // Make sure to add code blocks to your code group
      • ⑧UgFileUploadButton01-OnCmpleted事件

        當檔案上傳完成時,顯示檔案所在的目錄。

        //JScript
        function UgFileUploadButton01OnCompleted(sender,astream)
        {
            //遠端檔案路徑
            var DestFolder=UGSM.StartPath+"temp\\";
            var DestName=DestFolder+UgFileUploadButton01.FileName;
            //上傳檔案
            CopyFile(UGCM.GetFileStreamFileName(AStream), DestName, False);
            ugedit04.Text = DestName;
        }
        
        1
        2
        3
        4
        5
        6
        7
        8
        9
        10
        //PasScript
        procedure UgFileUploadButton01OnCompleted(sender: tobject;astream: tfilestream);
        var
          DestName : string;
          DestFolder : string;
        begin
            //遠端檔案路徑
            DestFolder:=UGSM.StartPath+'temp\';
            DestName:=DestFolder+UgFileUploadButton01.FileName;
            //上傳檔案
            CopyFile(UGCM.GetFileStreamFileName(AStream), DestName, False);
            ugedit04.Text := DestName;
        end;
        
        1
        2
        3
        4
        5
        6
        7
        8
        9
        10
        11
        12
        13
        // Make sure to add code blocks to your code group

        # 4. 運行結果

          使用滑鼠在FastWeb功能表,點選[儲存至資料庫]按鈕,將其儲存至資料庫,點選[除錯運行]確認能夠正常打開。

          點選[選擇檔案],打開檔案選擇界面,選擇檔案並確認后,填寫FTP上傳的相關參數,點選[上傳檔案],如果參數正確,顯示檔案上傳成功!字樣,點選[下載檔案],選擇的檔案會下載至本地。

        電子郵件(WEB)
        郵件發送-控制元件(WEB)

        ← 電子郵件(WEB) 郵件發送-控制元件(WEB)→

        Copyright © 2021-2025 愛招飛IsoFace | ALL Rights Reserved
        • 跟随系统
        • 浅色模式
        • 深色模式
        • 阅读模式