js无法对远程图片进行Base64转码

访问文件服务器文件,404错误,

解决方法:https://www.cnblogs.com/zyadmin/p/11122259.html

web端图片转成Base64码报错

Image from origin 'http://114.215.87.123:8900' has been blocked from loading by Cross-Origin Resource Sharing policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8002' is therefore not allowed access.
图像从起源“http://114.215.87.123:8900”已经被跨源阻止加载资源共享政策:没有提供“Access-Control-Allow-Origin”的头所请求的资源。起源“http://localhost:63342”因此不允许访问。

从提示信息内可以明显的看出错误在哪。

就是给IIS加上config文件。

新建一个web.config文件。

在里面填写内容:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
 <system.webServer>
   <httpProtocol>
     <customHeaders>
       <add name="Access-Control-Allow-Origin" value="*" />
     </customHeaders>
   </httpProtocol>
 </system.webServer>
</configuration>

然后重启IIS就可以了(也可以不用重启,如果不行就重启一下)。

 

posted @ 2016-07-17 16:53  大稳·杨  阅读(1962)  评论(0编辑  收藏  举报