The DownloadFile function is used to download a file from a specified file upload control, with an optional parameter to specify the file index if multiple files are uploaded.
Function Definition:
DownloadFile(Control name, FileIndex)
Parameters:
Example with Optional Argument
In this example, the function downloads the file at index 1 from the file upload control named FileUpload1. The FileIndex is provided, indicating which specific file to download if there are multiple files uploaded.
Figure1: Rule
Figure2: Designer
Figure 3: Preview (On clicking the “DownloadFile” button, print.pdf is downloaded)
Example without Optional Argument
In this example, the function downloads the file from the file upload control named FileUpload1 without specifying an index. This implies that the function will download the first file or the default file if only one file is present.
Figure4: rule
Figure 3: Preview (On clicking the “DownloadFile” button, Capture1.PNG is downloaded)
Practical Use
Summary
The DownloadFile function is a flexible way to handle file downloads from a file upload control within an application. By specifying the control name and optionally the file index, it allows for precise control over which file to download, making it useful for applications that involve file uploads and need to handle multiple files efficiently.