JAVA显示服务器上的多张图片,上传多张图片到微信服务器

html

选择图片

js

function uploadimg(me) {

wxshop.wx_config(function() {

wx.chooseimage({

count: 9, //设置一次能选择的图片的数量

sizetype: ['original', 'compressed'], //指定是原图还是压缩,默认二者都有

sourcetype: ['album','camera'], //可以指定来源是相册还是相机,默认二者都有

success: function(res) { //微信返回了一个资源对象

//res.localids 是一个数组 保存了用户一次性选择的所有图片的信息imgid = res.localids;

//把图片的路径保存在images[localid]中--图片本地的id信息,用于上传图片到微信浏览器时使用

ulloadtowechat(me); //把这些图片上传到微信服务器 一张一张的上传

}

});

});

}

function ulloadtowechat(me) {

wxshop.wx_config(function() {

if (!imgid.length) {

alert('图片上传成功!');

} else {

var localid = imgid.pop();

wx.uploadimage({

localid: localid,

success: function(res) {

wximgdown(res.serverid, me);//将图片路径存在了本地数据库

ulloadtowechat();

},

fail: function(res) {

alert(json.stringify(res));

}

});

}

});

};