加载本地文件时,谷歌浏览器出现错误

时间:2019-08-30 07:16:31

标签: javascript html google-chrome

我正在尝试使用javascript从网络摄像头保存照片,但在google-chrome中出现此错误:

Access to XMLHttpRequest at 'file:///C:/directory/upload.php' from origin 'null' has 
been blocked by CORS policy: Cross origin requests are only supported for protocol 
schemes: http, data, chrome, chrome-extension, https.

我试图做:

Use cmd prompt to run 
npm install http-server -g
to install a local server
(You need to have nodejs installed)

Then run 
http-server -p8000
from your working folder.

Open browser with address http://localhost:8000

但是无法识别http服务器。

您知道什么方法可以消除此错误吗?

0 个答案:

没有答案