[英]Javascript to load file
I want user upon clicking a button it will load the a txt file from a eg Desktop and display the contents. 我希望用户在单击按钮时将从例如桌面加载一个txt文件并显示其内容。
Can this be done? 能做到吗?
I found a lot of examples for loading a file but not displaying it. 我发现了很多加载文件但不显示文件的示例。
JavaScript in the browser can't access the user's file system - it would be a security issue. 浏览器中的JavaScript无法访问用户的文件系统-这将是一个安全问题。
Additionally, check out this SO question - the File API will allow this. 此外,请查看此SO问题 -File API将允许这样做。
There's an excellent tutorial on html5rocks.com, 'Reading Files in JavaScript using the File APIs', that shows how to use the FileReader interface: 在html5rocks.com上有一个很棒的教程,“使用文件API在JavaScript中读取文件”,其中显示了如何使用FileReader界面:
http://www.html5rocks.com/en/tutorials/file/dndfiles/ http://www.html5rocks.com/zh-CN/tutorials/file/dndfiles/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.