Successfully!

Error!

File Upload and Download Plugin

  • Last update:  2024-04-19
  • Overview

    Application Scenario

    Sometimes you may need to upload files to a server or an FTP server for storage and download files. Previously, you needed to customize functions with complicated codes in FineReport to achieve the function. With the File Upload and Download plugin (which encapsulates the function), you can conveniently and efficiently achieve the function by performing operations on a visualization page.

    Function Limitation

    • Ensure that your project supports the remote design, otherwise the plugin may not function properly.

    • When you upload multiple files in the same file widget, you cannot customize file names. Files with the same name are overwritten for display.

    • The path for upload and download cannot be the network path.

    • The values of extended cells cannot be read in the New Name function of File Download.

    • Dynamic calculation formulas are not supported in File Path of File Download.

    • File Download is not supported in dashboards.

    • Files cannot be deleted.

    • The file upload and download function is not supported on other remote servers, except the FTP server.

    • Cluster environments are not supported.

    • Only image files can be uploaded on mobile terminals. In addition, the download function is not supported on mobile terminals.

    • To upload files from a containerized environment to the host, a file mapping is required for the upload path between the container and the host.

    • For security reasons, you need to log in to the decision-making platform before downloading files.

    • The File Upload event cannot be set under Template > Web Attribute.

    iconNote:
    If you need to remove the above function limitations in actual scenarios, you can download the Advanced File Upload and Download plugin, which has more functions and covers more scenarios.

    Introduction

    Plugin Installation

    You can obtain the plugin at https://community.finereport.com/market/.

    For details about installing the plugin in the designer, see Designer Plugin Management.

    For details about installing the plugin on the server, see Server Plugin Management.

    Plugin Function

    Uploading Files to the Server

    Upload to Server is added to the drop-down list of Submission Type Selection in Custom Submission under Template > Data Entry Attribute.

    Overwrite File with Same Name is deselected by default. In this case, files with the same name will be automatically renamed. If you select Overwrite File with Same Name, files with the same name will be directly overwritten.

     1.png

    Uploading Files to the FTP Server

    Upload to FTP Server is added to the drop-down list of Submission Type Selection in Custom Submission under Template > Data Entry Attribute.

    Overwrite File with Same Name is deselected by default. In this case, files with the same name will be automatically renamed. If you select Overwrite File with Same Name, files with the same name will be directly overwritten.

     2.png

    File Download

    File Download is added in the drop-down list of Add Hyperlink. You can download files from the server by setting the hyperlink, as shown in the following figure.

     3.png

    Settings Format

    Setting Item
    ContentExample

    Upload Path/File Path

    Formula/fixed value

    A1

    On Windows: "D:/photo"

    In Linux and FTP: "/data/tomcat/"

    File

    Formula

    A1

    File Name

    Empty value/formula/fixed value

    A1

    "test2"

    Empty value (If File Name is empty, the file name will be automatically obtained.)

    New Name

    Empty value/formula/fixed value

    A1

    "test2"

    Empty value

    iconNote:

    1. If File Name is empty, the name of the uploaded file will be obtained by default. In this case, you can upload multiple files. If File Name is not empty, you cannot upload multiple files because files with the same name will be overwritten.

    2. The values of extended cells cannot be read in the New Name function of File Download. Dynamic calculation formulas are not supported in File Path of File Download.

    Example

    Report Design

    1. In the FineReport designer, Choose File > New General Report.

    2. Select cell A1, add File Widget to cell A1, and set File Type to All Files, as shown in the following figure.

     4.png

    Uploading Files to the Server

    1. Choose Template (on the designer menu bar) > Data Entry Attribute, select Custom Submission, set Submission Type Selection to Upload to Server, and set Disk Path, File, and File Name as needed, as shown in the following figure.

     5.png

    The following table describes each setting item.

    Setting Item
    Example in the Above FigureDescription

    Disk Path

    "C:/Users/Leo.Tsai/Desktop/Document/"

    Location for the file storage. Do not omit double quotation marks.

    File

    A1

    Cell number where the file widget is located.

    File Name

    Empty value

    Optional

    • If File Name is empty, the name of the uploaded file will be obtained by default. You can upload multiple files.

    • If File Name is not empty, you can generate the file name by customization or the formula. You cannot upload multiple files. Files with the same name will be overwritten.

    2. Save the report, click Data Entry Preview, upload the file, click Submit, and check the file storage location. You can view the uploaded file, as shown in the following figure.

     6.png

    Uploading Files to the FTP Server

    1. Choose Template > Data Entry Attribute, select Custom Submission, set Submission Type Selection to Upload to FTP Server, and click FTP Setting. The FTP Setting page pops up.

     7.png

    2. Click the + icon in the upper left corner of the FTP Setting page to create an FTP connection and enter the connection information as needed. Username and Password can be empty if not available, as shown in the following figure.

    iconNote:
    This configuration is at the server level and is saved in finedb. Therefore, you cannot directly copy the template to inherit the FTP configuration in a remote environment. You need to use the remote design function.

     8.png

    3. Set the file information, as shown in the following figure.

     9.png

    The following table describes each setting item.

    Setting Item
    Example in the Above FigureDescription

    Upload Path

    "/FineReport Document"

    Relative path of the file storage location. Do not omit double quotation marks.

    File

    A1

    Cell number where the file widget is located.

    File Name

    Empty value

    Optional

    • If File Name is empty, the name of the uploaded file will be obtained by default. You can upload multiple files.

    • If File Name is not empty, you can generate the file name by customization or the formula. You cannot upload multiple files. Files with the same name will be overwritten.

    FTP Site

    FTP Site 1

    FTP connection name created in the above step.

    4. Save the report, click Data Entry Preview, upload the file, click Submit, and check the file storage location. You can see the uploaded file, as shown in the following figure.

     10.png

    File Download

    1. Inserts the formula =filename(A1) into cell A2 to obtain the name of the uploaded file in cell A1. In addition, you can also obtain the file name through ways such as dataset fields and manual entering.

     11.png

    2. Select cell A2, click the Hyperlink icon on the right panel, and select File Download from the drop-down list of Add Hyperlink, as shown in the following figure. The following table describes each setting item.

    Setting Item
    Example in the Above FigureDescription

    File Service

    Default

    Allows you to download files from the server or the FTP server. If you select the FTP server, you need to select the corresponding FTP connection name.

    File Path

    "C:/Users/Leo.Tsai/Desktop/Document/Test.xlsx"

    Location of the disk or the FTP server where the file is located. Dynamic calculation formulas are not supported. Do not omit double quotation marks.

    New Name

    Empty value

    Optional and allows you to rename the downloaded file. The values of extended cells cannot be read.

    Encoding Type

    UTF-8

    Allows you to set the encoding type to match different encoding environments.

     12.png

    4. Save the report, click Data Entry Preview, and click the hyperlink to download the file, as shown in the following figure.

     13.png

    Template Download

    You can download the example template File Upload and Download.cpt.

    Attachment List


    Theme: Data Entry
    Already the First
    Already the Last
    • Helpful
    • Not helpful
    • Only read

    Doc Feedback