I. Overview
1. Application Scenario
Sometimes users need to upload files to the server or FTP for saving, and file downloads can be provided. In the past, the implementation of this function in FineReport required custom function implementation, but the code implementation would be more troublesome. This plugin encapsulates this function, and it can be operated through a visual interface after installation, which is convenient and fast.
2. Functional limitations
When uploading multiple files in the same file widget, custom file names are not supported and will be displayed overlapping
The file download rename function does not support reading extended cell values
The file download path does not support dynamic calculation formulas
File download does not support "Dashboard"
Deleting files is not supported
Cluster environment is not supported
The mobile terminal only supports uploading files of image type, and does not support uploading other files and downloading functions
Note: If the actual scene is affected by the above functional limitations, you can consider using the file upload and download plugin of the Enjoy version, which has more functions and covered scenes.
II. Plugin introduction
1. Plugin installation
Please click to download the plugin:
For the installation method of the designer plugin, refer to the designer plugin management
For the method of installing plugins on the server, please refer to Server Plugin Management
2. Plugin function
1) Upload to servere
In the report data entry attributes interface, the upload type selection has been added to the custom submit, and Upload to server can be selected.
Overwrite if name duplicates: Unchecked by default. When unchecked, the file with the same name will be renamed automatically; if checked, the file with the same name will be directly overwritten.

2) Upload to FTP
In the report data entry attribute interface, the upload type selection is added in the custom submit, and FTP Uploadcan be selected.
Overwrite if name duplicates: Unchecked by default. When unchecked, the file with the same name will be renamed automatically; if checked, the file with the same name will be directly overwritten.

3) File Download
A new option File Download has been added to the hyperlink. You can download a file from the server by setting a hyperlink, as shown in the following figure:

3. Setting item format
| Setting item | Content | Example |
|---|---|---|
| Upload path/file path | formula, fixed value |
|
| File | formula |
|
| File name | empty, formula, fixed value |
|
| Rename | empty, formula, fixed value |
|
Note 1: If the file name is empty, the uploaded file name will be obtained by default, and multiple file uploads are supported. If not empty, multi-file upload is not supported, and the file names will overlap.
Note 2: The download rename function does not support reading extended cell values. The file download path does not support dynamic calculation formulas.
III. Example
1. Report Design
1) Click File > New General Report in the FineReport Designer.
2) Select cell A1, add File Widget for cell A1, and select All Files for the file type. As shown below:

2. Upload to server
1) Click Template > Data Entry Attribute in the menu bar, add Custom Submit, select Upload to Server for the submission type, and enter the disk path, file, and file name according to the actual situation. As shown below:

The specific setting items are described in the following table:
| Setting item | This example | Description |
|---|---|---|
| Disk path | "C:/Users/43886/Desktop/Document/" | The location of files saved |
| File | A1 | The cell number where the file widget is located |
| File name | null | Optional
|
2) Save the report, click Data EntryPreview, upload the file, click Submit, and check the file save location to see the file just uploaded. As shown below:

3. Upload to FTP
1) On the menu bar, click Template > Data Entry Attribute, add Custom Submit, select FTP Upload for the submission type, click FTP Settings, and add an FTP connection.

2) To create a new FTP connection, the user needs to fill in the connection information according to the actual scene. If there is no user name and password, it can be omitted, as shown in the following figure:

Note: Sometimes the test connection will fail, but it does not affect file upload and download.
3) Set the file information, as shown below:

The description of each setting item is shown in the following table:
| Setting item | This example | Description |
|---|---|---|
| Upload path | "/FineReport Document" | The relative path to where the file is saved. An absolute path can also be used: "ftp://192.168.1.201/FineReport Document" |
| File | A1 | The cell number where the file widget is located |
| File name | Empty | Optional
|
| FTP site | FTP Site1 | FTP connection name in the second step of Section III.3 of this article |
4) Save the report, click Data Entry Preview, upload the file and submit it, check the file save location to see the file just uploaded. As shown below:

4. Download files
1) Insert the formula =filename(A1) into cell A2, which means to get the filename uploaded in cell A1. In addition to using formulas, you can also use dataset fields, handwritten file names, etc. to set.

2) Select cell A2, and add a "Hyperlink" of "File Download" type to the attribute panel on the right. The specific settings are as follows:
| Setting item | This example | Description |
|---|---|---|
| File service | Default | Supports downloading from the server or FTP, if it is FTP, you need to select the corresponding FTP connection name |
| File Path | "C:/Users/43886/Desktop/Document/Test.xlsx" | The disk or FTP location where the file is located. Dynamic calculation formulas are not supported. Relative paths can also be used: "/Test.xlsx" |
| Rename | Empty | Optional, you can rename the downloaded file, does not support reading extended cell values |
| Encode type | UTF-8 | The encoding can be set to match the environment of different encodings |

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