王豪
王豪
  • 发布:2016-09-14 10:50
  • 更新:2016-10-09 22:42
  • 阅读:2358

plus.gallery.pick打开相册读取图片 Not allowed to load local resource错误

分类:HTML5+

plus.gallery.pick(function(e){
plus.io.resolveLocalFileSystemURL(e, function(entry) {
mui.toast(entry.toLocalURL());
console.log(entry.toLocalURL());
document.getElementById("head-img").src = entry.toLocalURL();
document.getElementById("head-img1").src = entry;

                    });  
                },function(error){  
                    console.log(error);  
                });  

读取照片,把地址给img,就报错!
Not allowed to load local resource: file:///storage/emulated/0/news_article/80e890b34c1f181492a1abd5add0e7a0.jpg at http://115.28.6.7/rongyun.php/Home/Index/setting.html:0

2016-09-14 10:50 负责人:无 分享
已邀请:
7***@qq.com

7***@qq.com

我这个绝对没问题,因为我也是远程访问的webview。

//本地转换成平台
var newurl = plus.io.convertLocalFileSystemURL(dst);
//平台转对象
plus.io.resolveLocalFileSystemURL(newurl, function(entry) {
//对象转网络
newurl = entry.toRemoteURL();
$("#"+id).attr("src",newurl);
}, function ( e ) {
alert( "Resolve file URL failed: " + e.message );
} );

Trust

Trust - 少说废话

本地相册读取的路径已经是平台绝对路径,直接DOM.src = url即可。
可以参考Hello 5+示例项目中的源码。http://www.dcloud.io/runtime.html

plus.gallery.pick(function(path) {  
    console.log(path);  
    document.getElementById("img").src = path;  
}, function(e) {  
    console.log("取消选择图片");  
}, {  
    filename: "_doc/gallery/",  
    filter: "image"  
});  
  • 王豪 (作者)

    我用的是绝对路径呀

    2016-09-14 11:01

  • 王豪 (作者)

    问题不在这里在Not allowed to load local resource: file:///storage/emulated/0/news_article/80e890b34c1f181492a1abd5add0e7a0.jpg at http://115.28.6.7/rongyun.php/Home/Index/setting.html:0

    2016-09-14 11:05

  • 阿星蜀黍

    回复 王豪:问题解决了么,我遇到一样的问题了

    2017-08-16 18:59

该问题目前已经被锁定, 无法添加新回复