使用客户端JavaScript读取远程目录? [英] Read remote directory with client-side javascript?

查看:116
本文介绍了使用客户端JavaScript读取远程目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用JS扫描服务器上的目录,并创建指向目录中最新文件的链接。

I'd like to scan a directory on my server, using JS, and create a link to the most recent file in the dir.

我的服务器不支持t禁止目录列表;

My server doesn't disallow directory listings; I can see the contents of the folder if I navigate to it.

是否可以在纯JS中做到这一点?

Is it possible to do this in straight JS?

推荐答案

所有Javascript可以做的就是HTTP请求,并读取服务器响应的内容。如果您的服务器没有通过HTTP提供任何种类的目录列表,那么使用Javascript几乎无能为力。如果确实提供了目录列表,则可以尝试对其进行解析,但是您仍然不能仅使用客户端Javascript在服务器上创建任何文件或链接。这确实需要服务器端解决方案(PHP,Python,Ruby,C#,shell脚本;无论您愿意编写什么)。

All Javascript can do is HTTP requests and read whatever your server responds with. If your server doesn't give you any sort of directory listing over HTTP, then there's very little you can do with Javascript. If it does give you a directory listing you could try to parse it, but you still can't create any files or links on the server purely with client-side Javascript. This really calls for a server-side solution (PHP, Python, Ruby, C#, shell scripts; whatever you're comfortable writing).

这篇关于使用客户端JavaScript读取远程目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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