自定义文件选择器不使用< input type =" file" /> [英] Custom file picker without using <input type="file"/>

查看:224
本文介绍了自定义文件选择器不使用< input type =" file" />的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究一个基于java(webwork framework)的web应用程序,在这个应用程序中需要首先压缩要上传的文件。由于没有办法通过javascript设置input type ='file'元素的值,所以我决定采用嵌入式applet的路线。基本上这个小程序压缩所选的文件,然后通过scp将压缩文件上传到服务器。



它运行良好,但是我有关于网页本身渲染的问题。我想,而不是实现文件选择器内的小程序,如果有一个现有的文件选择器,我可以使用。当然,不要把任何输入类型=文件。

链接到这些现有的自定义网络文件选取器将非常赞赏。由于安全限制,选择HTML文件的唯一方法是添加< input type = file> 到文件。然后用户应该选择一个真正的点击文件。

请注意,JavaScript是能够(在现代浏览器)阅读文件的内容,所以它不应该能够选择任意文件并读取它。


I am working on a java-based (webwork framework) web-app where the file to be uploaded needs to be compressed first. Since there's no way to set the value of "input type='file'" element via javascript, I decided to take the route of an embedded applet. Basically this applet compresses the chosen file, then uploads the compressed file to the server via scp.

It worked well, but I have issues regarding the rendering of the web page itself. I am thinking instead of implementing the file picker within the applet, if there's an existing file picker that I can use instead. Of course without putting any "input type='file'".

Links to these existing custom web file pickers will be very much appreciated.

解决方案

Due to security restrictions the only way to select a file with HTML is adding an <input type=file> to document. Then user should selects a file with real clicks.

Note that javascript is able (in modern browsers) to read the content of file, so it should not be able to select arbitrary file and read it.

这篇关于自定义文件选择器不使用&lt; input type =&quot; file&quot; /&gt;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆