Validate File Size Before Upload
Setting Size Limit Constants
To set a file size limit, you first need to know what the system or environment limit is. For a Logi .NET application, the default maximum upload size is governed by the .NET Framework limit, which is 4MB. This may have been changed by the system administrator, to allow larger files or smaller files. You can find this value in the web.config file in your application folder or in the application's parent web.config file under the <system.web> section, as explained in Controlling Maximum File Size.
Once the existing limits are known, you'll need to add two Constants in the _Settings definition:
The examples shown above set a limit of 25MB. Use the ratio 1MB = 1,024KB to determine the values.
Setting Up the Elements
An example arrangement of elements is shown below:
The script uses the element IDs shown in the example above; if you use different IDs, edit the script to match.
The standard Input File Upload element "file" is used to select the desired file for upload.
The Division element "div_UploadBtn" uses a Condition expression to show or hide the Upload button so the user has a visual clue that the selected file is ready for upload. Its Class attribute is set to ThemeHidden (or a similar display:none class) so that it, and the Upload button, are initially hidden from view.
The optional Popup Panel element "pp_LargeFile" is being used here to give the user feedback if the file exceeds the size limit.