且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Angular 2应用程序-链接到本地​​文件

更新时间:2023-11-22 19:51:22

您不能从通过http服务的网站***问本地资源,因为这是出于安全考虑.想一想,如果任何网站可以访问计算机上的文件,会对您的计算机造成什么影响.对于从您所在域以外的其他域提供数据,您还将受到其他安全限制.

You cannot access local resources from a website served over http because it is a security concern. Think of what would happen to your machine if any website could access files on it. You'll have other security restrictions for serving data from a different domain from your domain as well.

您到底想通过访问本地文件来完成什么?进一步了解原因可能会为您提供更多有用的建议.否则,答案是您不能也不应这样做.

What exactly are you trying to accomplish by accessing a local file? Giving additional insight into the reason might get you more useful suggestions. Otherwise, the answer is that you can't and shouldn't do this.