问题描述
有很多使用html5读取本地文件的例子,但是通过从文件列表中选择,我的问题是我想手动创建文件对象,想想我有一个链接文件
file:/// G:/Users/txt.txt
我希望浏览器打开它,
我认为它必须File f = new File(' file:/// G:/Users/txt.txt');
我的问题是如何创建/初始化文件对象文件路径 ?!
真的没有办法在未经用户许可的情况下创建文件。需要按下按钮或其他东西。您需要创建一个数据:uri才能保存。您可以使用网络搜索或查看(不是完整的来源,但可以显示可能的内容)。这取决于手机和操作系统,这是非常有限的。数据URI在使用IE时受到限制。
当它被触发下载时,它会保存到默认位置或用户指定的位置。您可能还想查看可以按照您的描述执行的供应商/操作系统特定的API调用。但可能需要在实际允许访问之前验证权限。
there is many examples of reading local files using html5 but by choosing from list of files , my problem is that i want to create the file object manually , think about i have a file with the link
file:///G:/Users/txt.txt
i want the browser to open it ,
i think it have to File f=new File('file:///G:/Users/txt.txt');
my question is how to create/initialize the file object using file path ?!
There really is no way to create a file without permission from the user. A button or something will need to be pressed. You would need to create a data:uri in order for it to save. You can find more information using a web search or checking out http://en.wikipedia.org/wiki/Data_URI_scheme (not a complete source but can show what is possible). This is very limited depending on phone and OS. Data URI are limited while using IE.
When it is triggered for download, it saves to t he default location or user specified. You may also want to look into vendor/OS specific API Calls that can do as you are describing. But may need to verify permissions prior to actually allowing access.
这篇关于如何使用文件路径html5创建/初始化文件对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!