Limiting MIME types with IBM Lotus Domino 8.5 XPage file upload control
2011-03-04 22:05
811 查看
Abstract No abstract provided. | ||||||||||||||||||
ShowTable of Contents HideTable of Contents 1 Introduction 2 Adding the upload control to your XPage or custom control 3 Using the file download control to find MIME types 4 Notifying the user when an invalid file is submitted 5 Conclusion 6 Resources 7 About the author Summary: Currently the IBM® Lotus® Domino® 8.5 XPage upload control allows you to upload a file into an XPage application. In certain cases, however, you may want to limit what types of files a user can upload. This article describes how to configure the upload control for your needs and how to alert users when incorrect file types are submitted. IntroductionDoes your application allow users to upload images, but you find that all types of files are being uploaded? Do you want to prevent users from uploading executable files into your application? This article explains how to configure the XPage upload control, to limit what MIME types can be uploaded into your application. MIME, or Internet MediaType as it is now referred to, describes the content that is being uploaded into your application. Adding the upload control to your XPage or custom controlYou can add the upload control to any XPage or custom control by simply dragging it from the core controls panel in Lotus Domino Designer and placing it in the desired location (see figure 1).Figure 1. Upload control in an XPage To limit the file upload control to accept only a certain MIME type: 1. Once you have the control in place, select the Properties tab > All Properties for the control (see figure 2). 2. Under the Property column, select the accept property, and then click on the Value column. You will see a drop-down list of default file types from which to choose. Figure 2. List of default file types This is fine if you want the file upload control to accept only one MIME type, but what if you need a MIME type that is not listed, or you need to accept multiple MIME types? In these cases, you can compute the value of the accept property so that you can accept a file type that is not listed, or accept multiple file types. To do this, click on the blue diamond (on the far right-hand side in figure 2 above) and select compute value. If you want the upload control to accept only images, you can compute the value as shown in figure 3, separating each MIME type with a comma. Figure 3. JavaScript expression to compute the accept property value Click OK; you now see the computed value for the accept property in the Value column, as shown in figure 4. Figure 4. Computed value displayed in Value column Using the file download control to find MIME typesWhat if you want to add a new MIME type but are unsure what the MIME type is for a given file, such as a PDF?To help in figuring out what a MIME type is for a given file, you can use the file download control along with the file upload control to display the MIME type for any file (see figure 5). Figure 5. File download control from a Web browser To add the download control to your XPage or custom control, simply drag the control from the core controls panel in Lotus Domino designer and add it to the desired location. Once you've added the control, under the Properties tab, select File Download, and in the Options section make sure Type (the default) is selected (see figure 6). Figure 6. File Download options Now, before restricting the upload control to certain MIME types, you'll be able to verify the MIME types before you add them to the upload control. Notifying the user when an invalid file is submittedIf you are configuring the upload control to accept only certain MIME types, you may want to alert users when they try to upload a file whose MIME type is not allowed for upload. To do this:1. Add the message control to your XPage or custom control. 2. Next, under the Properties tab, select Display Error, and in the Name field enter a name for the control. 3. Click on the drop-down for the “Show error messages for” field andbind it to the field that would generate an error in the case of the upload control (see figure 7). Figure 7. Message control configuration Once the message control is configured, you'll see the following message if, for example, the upload control does not allow MIME types of text/plain: ConclusionWith the new XPage upload control you now have greater control over what type of files your application will accept. This provides greater flexibility, for example, by ensuring that only image files are uploaded when you ask for a profile photo or ensuring that only spreadsheet files are uploaded when you request expense reports.ResourcesNotes and Domino information center:http://publib.boulder.ibm.com/infocenter/domhelp/v8r0/index.jsp IBM Lotus Support document, “Knowledge Collection: XPages”: http://www-01.ibm.com/support/docview.wss?uid=swg27014929 IBM Lotus Support document, "Preview in Web Browser" option grayed out for custom controls”: http://www-01.ibm.com/support/docview.wss?uid=swg21366584 About the authorKevin Giles is an IBM Advisory Software Engineer currently working as an application developer and system administrator for the IBM developerWorks® Lotus Web site. He joined Iris Associates, now part of IBM, in 1997, where he worked on the original Notes.net Web site. In past roles he also worked as a quality assurance tester for Lotus Domino. Kevin is an IBM Certified Advanced Application Developer.Article information Article information
|
相关文章推荐
- Asp:UpdatePanel with FileUpload Control inside.
- IBM Lotus Notes/Domino 8.5 Forum (includes Lotus Notes Traveler)
- IBM Lotus Domino 8.5 配置指南
- Limiting Upload File Size with Django Forms
- 推荐:IBM Lotus Domino 8.5 服务器管理入门手册(适用初学者)
- ajaxfileupload上传文件,返回json数据报错的问题。 Resource interpreted as Document but transferred with MIME type ap
- This control will present the user with an upload file dialog box
- RHEL5 下安装IBM Lotus Domino 8.5
- IBM Lotus Domino 8.5 配置指南
- 在 IBM Tivoli Access Manager 保护的环境中实现 Lotus Quickr 8.5(Domino base) 和 Lotus Connections 2.5 的集成
- IBM Lotus Domino 8.5 配置指南
- IBM Lotus Domino 8.5 服务器管理入门手册
- IBM Lotus Domino V8.5 服务器管理入门手册
- IBM Lotus Domino V8.5 服务器管理入门手册
- IBM Lotus Domino 8.5 服务器管理入门手册
- 推荐:IBM Lotus Domino 8.5 服务器管理入门手册(适用初学者)
- FileUpload Control Validation
- IBM LOTUS DOMINO 9 部署SSL证书
- FileUpload Control In ASP.NET2.0
- File Upload with Jersey