Validating MIME Types for Uploaded Files
You can specify the MIME types for uploaded files using the ValidMimeTypes property. Once the MIME types are set for the ValidMimeTypes property, C1Upload automatically validates the specified MIME types.
Setting the ValidMimeTypes Property in Design View:
To set the ValidMimeTypes property, complete the following steps:
1. Click the Design button to enter Design view.
2. Right-click the C1Upload control to open its context menu and select Properties from the list.
The Properties window opens with the C1Upload’s control properties in focus.
3. Set the ValidMimeTypes property to “ai, aif, aps”.
4. Press F5 to build the project and try adding files with extensions other than .ai, .aif, and .aps. Notice that those files are not placed into the physical or virtual target folder since they didn’t meet the file extension requirements that you specified for the ValidMimeTypes property.
Setting the ValidMimeTypes Property in Source View:
To set the ValidMimeTypes property, complete the following steps:
1. Click the Source button to enter Source view.
2. Place the ValidMimeTypes="ai,aif,aps" in the <cc1:C1Upload> tag so that the markup resembles the following:
<cc1:C1Upload id="C1Upload1" runat="server"
ValidMimeTypes="ai,aif,aps" />
3. Press F5 to build the project and try adding file with extensions other than .ai, .aif and .aps. Notice that those files are not placed into the physical or virtual target folder since they didn’t meet the file extension requirements that you specified for the ValidMimeTypes property.
Setting the ValidMimeTypes Property in the Code-behind file:
In the code-behind, assign the value of the ValidMimeTypes property to a string array, like the following:
1. On the Visual Studio toolbar, click View | Code to enter Code view.
2. Import the following namespace into your project:
Imports C1.Web.UI.Controls.C1Upload
• C#
using C1.Web.UI.Controls.C1Upload;
3. Assign the value of the ValidMimeTypes property by adding the following code into the Page_Load event:
C1Upload1.ValidMimeTypes = New String() {".ai", ".aif", ".aps"}
• C#
C1Upload1.ValidMimeTypes = new string[] {".ai", ".aif", ".aps"};
|