Get full path of selected file in JSF

社会主义新天地 提交于 2019-12-01 14:39:10

The JSF <h:inputFile> component generates a HTML <input type="file"> element which is officially only capable of sending the file content along with the sole file name — although certain browsers, particularly the one developed by some team in Redmond, also send the full file path along with the file name due to a security bug; which should thus certainly not be relied upon as it may be fixed and removed in future versions.

In HTML terms, there does not exist any element which allows the enduser to select a full file path from its local disk file system and send it in its entirety (without the associated file content) to the server. Since JSF is in the context of this question merely a HTML code producer, it isn't possible in JSF either.

Consider creating a Swing based Applet which you in turn embed the usual way in your HTML page (or JSF page, depending on the perspective how you interpret things). The Swing JFileChooser is capable of the task of selecting a local disk file system location and obtaining the full path. You can in turn send this information via URLConnection to the server (don't forget to sign the applet to avoid bothering and worrying the enduser about the security warnings it may produce).

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!