5***@qq.com
5***@qq.com
  • 发布:2017-07-30 23:07
  • 更新:2017-08-14 23:21
  • 阅读:1965

想问下XMLHTTP 获取的图像数据,如何保存到本机,并显示到IMG SRC,数据有正常获取,现在就是保存后没有反应。能帮看一下吗?谢谢了!

分类:HTML5+

if(xsxszp.status == 200) {
//alert(xsxszp.response)
//$id('xszp').src=xsxszp.response

                    plus.io.resolveLocalFileSystemURL(  
                        '_downloads/userInfo.JPG',  
                        function(entry) {  
                            //entry.getFile('_downloads/userInfo.JPG', '','' , '')  
                            entry.createWriter(function(writer) {  
                                writer.onwrite = function(e) {  
                                    //$id('xszp').src = '_downloads/userInfo.JPG'  
                                    plus.console.log("Write data success!");  
                                };  
                                writer.seek(0);  
                                writer.write(xsxszp.response);  
                            }, function(e) {  
                                alert(e.message);  
                            })  
                        }  
                    )  
                }
2017-07-30 23:07 负责人:无 分享
已邀请:
wenju

wenju - https://www.mescroll.com -- 精致的下拉刷新和上拉加载组件

//XMLHttpRequest方式读取图片字节流  
            var xhr = new XMLHttpRequest();  
            xhr.open("get", 'http://zxxs.fjedu.gov.cn/skins/images/l5/ok.png', true);  
            xhr.responseType = "blob";  
            xhr.onload = function() {  
                if(xhr.status == 200) {  
                    var blob = xhr.response;  
                    document.getElementById("imgres").src = window.URL.createObjectURL(blob);  
                }  
            }  
            xhr.send();
DCloud_heavensoft

DCloud_heavensoft

为何不用plus的download api下载图片到本地?

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