[英]how to read xml from FTP server in javascript
I am new to Javascript. 我是Java语言的新手。 Please tell me that how to retrieve and read XML file which is placed on ftp server in Javascript.
请告诉我,如何检索和读取Javascript中放置在ftp服务器上的XML文件。 Javascript only speaks HTTP and WebSockets (on newer browsers), and not FTP
Javascript仅讲HTTP和WebSockets(在较新的浏览器上),而不讲FTP
If you are speaking about client side Javascript
(the one that is in the browser), then this is not possible (it can understand only HTTP
protocol and with the rise of HTML5
also WebSockets
). 如果要谈论客户端
Javascript
(浏览器中的Javascript
),那么这是不可能的(它只能理解HTTP
协议,随着HTML5
的兴起也可以理解WebSockets
)。 FTP
is completely another protocol and hence this is not possible. FTP
完全是另一个协议,因此这是不可能的。
Think about it this way: your JS is stored in your browser. 这样考虑:您的JS存储在浏览器中。 So the whole code that will connect to your FTP and do something there is exposed to everyone.
因此,将连接到您的FTP并在其中执行某些操作的整个代码向所有人公开。 In order to connect to FTP you need to provide your credentials (your username and password).
为了连接到FTP,您需要提供您的凭据(您的用户名和密码)。 This means that everyone who wants to get them can get them.
这意味着每个想要得到它们的人都可以得到它们。 This is not nice :-).
这不是很好:-)。
As I understand, the thing you want to achieve - user does something on your site (click a button) and he can download the file from the ftp. 据我了解,您要实现的目标-用户在您的站点上执行了某些操作(单击按钮),然后他可以从ftp下载文件。 In this case I would do something like this.
在这种情况下,我会做这样的事情。 On click I will make an
ajax call
or some sort of redirect ( window.open('http://yourserver/getFile.php');
) And the script in getFile.php (php does not matter here - this is any server side script python, asp, ...) connects to your FTP server and does whatever you want. 单击时,我将进行
ajax call
或某种重定向( window.open('http://yourserver/getFile.php');
)和getFile.php中的脚本(php在这里无关紧要-这是任何服务器辅助脚本python,asp,...)连接到FTP服务器,然后执行您想要的任何操作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.