设为首页 收藏本站
查看: 854|回复: 0

[经验分享] Limiting MIME types with IBM Lotus Domino 8.5 XPage file upload control

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2015-10-4 00:34:44 | 显示全部楼层 |阅读模式



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.
Introduction

Does 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 Media Type 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 control

You 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 types

What 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 submitted
  
  

If 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:

  Conclusion
  

  With 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.
  

  Resources
  
  Notes 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 author

Kevin 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




Category:
Developing XPage Applications, Resources for Developers, Using Core Controls,
Tags:
controls, Xpage, upload control
This Version:Version 42010年3月5日下午04:02:21by Kevin Giles  
Originally Added:Version 12010年3月2日上午09:02:49by Kevin Giles  

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-122270-1-1.html 上篇帖子: IBM CellBE Workshop内容和重点 下篇帖子: IBM如何做知识管理
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表