如何配置Apache 2以允许访问计算机的本地驱动器上的文件?(How to configure Apache 2 to allow access to files on local drives o

编程入门 行业动态 更新时间:2024-10-28 11:22:58
如何配置Apache 2以允许访问计算机的本地驱动器上的文件?(How to configure Apache 2 to allow access to files on local drives of computer?)

我正在做一个项目,我正在使用AngularJS的特征指令。 我的指令代码如下:

app.directive('programListing', function() { return { restrict:'E', scope: { listing:'=' }, templateUrl:'js/directives/programListing.html' }; });

每当我尝试在Chrome上加载index.html ,它都会给出: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource. 错误。 我尝试通过Apache服务器2加载index.html但它给出: Not allowed to load local resource错误,因为我的index.html文件包含来自本地驱动器的一些图像。 那么,如何配置Apache 2以便它从我的计算机的本地驱动器访问文件,这样我也可以离线完成我的工作。 提前致谢!! :-)

I'm doing a project where I'm using directives characteristic of AngularJS. Code of my directive looks like this:

app.directive('programListing', function() { return { restrict:'E', scope: { listing:'=' }, templateUrl:'js/directives/programListing.html' }; });

Whenever I try to load index.html on Chrome it gives: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource. error. I tried loading index.html through Apache server 2 but it gives: Not allowed to load local resource error, due to the fact that my index.html file contains some images from local drives. So, how to configure Apache 2 so that it access files from local drives of my computer, so that I can do my work offline too. Thanks in advance!! :-)

最满意答案

我得到了答案!! 通过稍微更改本地文件上的图像地址来解决问题。 首先,我将图像文件放在Apache文件的htdocs文件夹中,然后我用它作为我的文件地址: http://localhost/image-name.jpg这解决了这个问题。

I got an answer!! The problem get solved by slightly changing the image address on the local file. Firstly, I placed the image file inside htdocs folder of Apache files, then I used this as my address to the file: http://localhost/image-name.jpg This solved the problem.

更多推荐

本文发布于:2023-07-20 12:49:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1199688.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:器上   文件   计算机   configure   Apache

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!