使用 jquery 和 Asp.Net 从代码隐藏中获取文件夹详细信息
我的服务器文件夹上有一些图像,我想知道有没有办法获取该文件夹路径和该文件夹中图像的文件名。
我如何访问它们?
这是我的文件夹结构的样子:
我知道这是一个安全问题,所以我想知道我已经使用服务器端代码完成了该操作,但我想将该文件夹从代码隐藏获取到 jquery。 这可能吗?
这就是我尝试在服务器上创建文件夹的方式,并且可以使用 jquery 检索该文件夹:
IO.Directory.CreateDirectory(Server.MapPath("Uploads/" & tempDir))
I have some images on my server folder and I would like to know is there a way to get that folder path and the filenames of images in that folder.
How do I access them?
This is how my folder structure looks like:
I understood that its a security issue and so I would like to know that I have done that using server side code but I would like to get that folder from codebehind to jquery.
Is that possible?
This is how I am trying to create a folder on my server and this can be retrieved using jquery:
IO.Directory.CreateDirectory(Server.MapPath("Uploads/" & tempDir))
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您必须在正在渲染的页面中输出它们。
因此,首先您需要在服务器上构建文件集合,然后将该列表输出到页面上,也许输出到隐藏字段中。然后您可以使用 JavaScript 读取该字段。
另一种替代方法是在 IIS 中启用目录浏览,然后对该目录执行 GET 请求。
You would have to output them in the page you are rendering.
So first you would need to build a collection of files on the server, then output that list on the page, perhaps in to a hidden field. You could then read this field using JavaScript.
Another alternative would be to enable directory browsing in IIS and then performing a GET request on that directory.
您无法通过 Javascript 访问计算机的文件和目录。这是一个安全问题。您需要使用服务器端语言。
编辑:除非你使用node.js
You can't access your computers' files and directories from Javascript. This is a security issue. You need to use a server side language.
EDIT: Unless you use node.js