Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
579 views
in Technique[技术] by (71.8m points)

javascript - 无法打开本地文件-Chrome:不允许加载本地资源(Cannot open local file - Chrome: Not allowed to load local resource)

Test browser: Version of Chrome: 52.0.2743.116(测试浏览器:Chrome版本:52.0.2743.116)

It is a simple javascript that is to open an image file from local like 'C:\002.jpg'(这是一个简单的JavaScript,可以从本地打开图像文件,例如“ C:\ 002.jpg”)

function run(){

   var URL = "file:///C:02.jpg";

   window.open(URL, null);

}
run();

Here is my sample code.(这是我的示例代码。)

https://fiddle.jshell.net/q326vLya/3/(https://fiddle.jshell.net/q326vLya/3/)

Please give me any suitable suggestions.(请给我任何合适的建议。)

  ask by KBH translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Know this is kind of old, but see many questions like this...(知道这有点老了,但是看到很多这样的问题...)

We use Chrome a lot in the classroom and it is a must to working with local files.(我们在课堂上经常使用Chrome,这是处理本地文件的必备条件。)

What we have been using is "Web Server for Chrome".(我们一直在使用的是“ Chrome浏览器的Web服务器”。)

You start it up, choose the folder wishing to work with and go to URL (like 127.0.0.1:port you chose)(启动它,选择希望使用的文件夹,然后转到URL(例如127.0.0.1:您选择的端口))

It is a simple server and cannot use PHP but for simple work, might be your solution:(这是一个简单的服务器,不能使用PHP,但是为了简单的工作,可能是您的解决方案:)

https://chrome.google.com/webstore/detail/web-server-for-chrome/ofhbbkphhbklhfoeikjpcbhemlocgigb(https://chrome.google.com/webstore/detail/web-server-for-chrome/ofhbbkphhbklhfoeikjpcbhemlocgigb)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...