开发者

how to access file in javascript? [duplicate]

This question already has answers here: Local file access with JavaScript (14 answers) Closed 8 years ago.

Is it possible to access file with extension 开发者_运维知识库*.txt or *.file in JavaScript? I want to call this file in my function?


If you are talking about javascript running in a web browser then the answer is no, you cannot access files on the client computer unless you use some proprietary technology like Silverlight, ActiveX, Flash, ...

If you want to access files stored on the server then you could use AJAX to query a server side script which would return the contents of the file.


You will not be able to read the file contents using javascript which is executed in a browser. Since javascript runs in a client browser reading a file from the file system will be a secirity threat.


As of HTML5 there are new features for file access, see https://stackoverflow.com/a/7056216/356726

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜