如何在javascript中访问文件? [英] how to access file in javascript?

查看:77
本文介绍了如何在javascript中访问文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在JavaScript中访问扩展名为* .txt或* .file的文件?
我想在我的函数中调用这个文件?

Is it possible to access file with extension *.txt or *.file in JavaScript? I want to call this file in my function?

推荐答案

如果你在谈论在网络浏览器中运行的javascript答案是否定的,你不能访问客户端计算机上的文件,除非你使用Silverlight,ActiveX,Flash等专有技术......

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, ...

如果你想访问存储在服务器上的文件然后您可以使用AJAX查询将返回文件内容的服务器端脚本。

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.

这篇关于如何在javascript中访问文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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