[英]How to gain javascript data from a file using a filereader api
I do not understand why this code is not working I am new to coding in javascript and I can't figure out the filereader. 我不明白为什么此代码无法正常工作,我是使用JavaScript编码的新手,无法弄清filereader。
var reader = new FileReader();
reader.onload = function {
var data = reader.result;
alert(data);
};
reader.readAsText("file:///C:/test.txt");
simply put, you cannot access the clients Filesystem with javascript. 简而言之,您无法使用javascript访问客户端文件系统。 it's a security measure.
这是一种安全措施。 you can't use the
file
protocol. 您不能使用
file
协议。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.