[英]How to load all the file names from a sub folder into my secure web page, using jQuery/JavaScript
I have a sub folder named "images". 我有一个名为“ images”的子文件夹。 I want to load all the file names from "images" folder into my html page using jQuery/JavaScript on a secure web site. 我想使用安全网站上的jQuery / JavaScript将“ images”文件夹中的所有文件名加载到html页面中。
How can I do this? 我怎样才能做到这一点?
I know how to do this for an unsecured site: How to load all the images from one of my folder into my web page, using Jquery/Javascript 我知道如何针对不安全的网站执行此操作: 如何使用Jquery / Javascript将文件夹中的所有图像加载到我的网页中
EDITED: It's an https page. 编辑:这是一个https页面。 I can get the contents of a folder in an http page, but I get an '403 - Forbidden: Access is denied.' 我可以在http页面中获得文件夹的内容,但得到的是“ 403-禁止访问被拒绝”。 error for the folder in an https page. https页面中的文件夹错误。 I have access to webserver. 我可以访问网络服务器。 I use ASP.NET and tried to set permissions in web.config on the folder for all users. 我使用ASP.NET,并尝试为所有用户在该文件夹的web.config中设置权限。 I want to get the list from the client side. 我想从客户端获取列表。 The client script is executed through the same-origin policy. 客户端脚本通过同源策略执行。 I use an ASP.NET web page (but I want to get the files through JavaScript/jQuery). 我使用ASP.NET网页(但是我想通过JavaScript / jQuery获取文件)。 I might use web services. 我可能会使用Web服务。
Thanks for the details. 感谢您的详细信息。 Im sorry I cant set up an ASP.Net website right now, but I still have a few questions. 抱歉,我现在无法建立ASP.Net网站,但是我仍然有几个问题。
Is the client script executed through the same-origin policy or do you need to enable CORS / JSONP ? 客户端脚本是否通过同源策略执行,还是需要启用CORS / JSONP? https://docs.microsoft.com/en-us/aspnet/web-api/overview/security/enabling-cross-origin-requests-in-web-api https://docs.microsoft.com/zh-cn/aspnet/web-api/overview/security/enabling-cross-origin-requests-in-web-api
Do you use ASP.Net WebPage, MVC, WebApi, which version or the new ASP.Net Core version? 您是否使用ASP.Net WebPage,MVC,WebApi,哪个版本或新的ASP.Net Core版本?
My recommendation is to build a webservice/API that reads the folder and delivers the list of files: 我的建议是构建一个可读取文件夹并提供文件列表的webservice / API:
With WebApi this might helps: https://stackoverflow.com/a/25986573/117314 借助WebApi,这可能会有所帮助: https ://stackoverflow.com/a/25986573/117314
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.