File Download
Description
The download part is located in form nodes and it allows application end users to download specified files to their file system from a LogicNets-based application. This part is often used in conjunction with the file upload part.
Use
This part is located in the general form nodes for general applications and in form-part nodes for applications built using the Assessment Framework. It allows the application developer to provide a list of files in a collection, directory path, or data table for application users to download. Users can download the selected file or files to a local system or open the file in a new browser if the browser supports that file type.
LogicNets accepts all file types for download; however, the files will only open in the browser if the browser allows that file type.
Tips & Tricks
Often an application will have BOTH the file upload and file download parts included, so a user can upload file(s) and the same (or different) user can see what has been uploaded, and choose to download if required. In this case, it is important to match the parameters in both parts.
- When using Source = Directory, match Storage Location and Sub Folder.
- When checking Unique File Name in the file upload, and downloading by file, select the correct data object name containing the new filename/path for the download source. Run your project in TEST and click on the data tab to search for/find the data object name.
Editor Fields
When adding a file download option to an application, the application developer uses the following fields.
Field Name | Description/Use | Type/Options | Optional/Mandatory |
HTML enabled |
When this is enabled you can put HTML formatting in the Question caption, which means the system will display HTML tags in the text in the caption editor as they would appear in a browser. The editor browser provides limited HTML editing options for text formatting. You can toggle the HTML-enabled button on and off to alternate between seeing and editing tags and displaying them as they will appear. | Yes | No | Optional |
Question | This field should contain any text you want to display to the user. | Text | Optional |
Options | These are the download options.
|
Dropdown Menu | Mandatory |
Directory | This is the storage location of the files for download by the download control. | Text | Mandatory |
Sub folder | This option becomes available when the storage location is set to '(local) \appdata' or '(local) \temp'. It allows you to specify the subfolder within the given directory to which the file(s) must be uploaded. If the sub folder was specified in the File Upload part, then match the parameter here to be able to see uploaded files. |
Text | Optional |
(whitelisted) Path | This option becomes available when the storage location is set to 'external directory'. It allows you to specify the path to the external directory. NOTE: External directories must be whitelisted in the settings.cfg file before the file can be downloaded. | Text | Mandatory |
Storage location | This is the storage location of the file(s):
|
Dropdown Menu | Mandatory |
File type filter | This field allows you to specify file type filters separated by a colon; for example, “.txt, .css, .html”. In this case, the system will only display files of type txt, css, or html. If the application developer does not set a filter type the system displays all available files. | Text (case sensitive) | Optional |
Action | This parameter specifies the possible actions for the user:
|
Dropdown Menu | Mandatory |
Show stamp | If you check this checkbox the system shows an additional column for the time stamps of the files in the downloaded result. | Checkbox | Optional |
Show delete button | If you check this checkbox the system will display a file delete button in the actions list. This allows users to remove a file from the list. | Checkbox | Optional |
Submit after delete | If you click this checkbox the system will step the logicnet forward when the user clicks the delete button. This would allow you to display the outcome of the delete action, for example. | Checkbox | Optional |
Deleted file (data object) | This option is only available if 'show delete button' is activated. When a user deletes a file, the system saves the following information on the provided location:
|
Text | Optional |
Custom headers | If you check this box the system displays your custom text instead of the predefined table headers. You enter the custom text in the following fields. | Checkbox | Optional |
Custom header: Caption | This option is only available if 'Custom headers' is activated. This field holds the text the system will display as the header instead of the default value 'Caption'. | Text | Optional |
Custom header: Time stamp | This option is only available if 'Custom headers' is activated. This field holds the text the system will display instead of the default value 'Time stamp'. | Text | Optional |
Custom header: Actions | This option is only available if 'Custom headers' is activated. This field holds the text the system will display instead of the default value 'Actions'. | Text | Optional |
Directly start download | If you check this option the system downloads the item specified in the ItemId field. The ItemId points to the item in the collection (index) or the Id of the record in the database table. The system will not display the download control. | Checkbox | Optional |
Styling
The file upload and download parts contain the standard form part template in the Assessment Framework, and in that use case are presented on screen in the same style as regular form parts for radiolists and checklists. Additionally, its is possible to use the part CSS class in the style tab to assign additional CSS declarations.
In LogicNets versions up to and including v7.3, to override the default styling of the table with all the files you must override the file_download_table class in your custom CSS file. For example, .file_download_table { font-size:16px; }
Hiding an Empty Download Table
The download part will display on screen regardless of the number of files it presents (with no files in the specified location/directories, the titles will still appear. You can hide the table with the following CSS (which hides the table unless there is a second row - the first file listed)
Note there is a different solution for Firefox browsers outlined here – you should add this if you anticipate users browsing with Firefox.
https://developer.mozilla.org/en-US/docs/Web/CSS/:has
Example
Please download and import the following example project to your workspace.