码迷,mamicode.com
首页 > 微信 > 详细

微信图片上传接口多图像上传(递归上传)

时间:2015-09-25 18:22:29      阅读:339      评论:0      收藏:0      [点我收藏+]

标签:

/*	微信上传
		-----------------------------------------------------------------------*/

		wx.config({
			debug: true,
			appId: ‘<?php echo $conf["appID"]; ?>‘,
			timestamp: <?php echo $upload["time"]; ?>,
			nonceStr: ‘<?php echo $upload["nonce"]  ?>‘,
			signature: ‘<?php echo $signature; ?>‘,
			jsApiList: [‘chooseImage‘, ‘uploadImage‘, ‘downloadImage‘, ‘previewImage‘]
		});




		wx.ready(function() {
			document.getElementById(‘list-photo‘).onclick = function() {
				var images = {localIds:[],serverId:[]};

				wx.chooseImage({
					count: 9,
					sizeType: [‘original‘, ‘compressed‘],
					sourceType: [‘album‘],
					success: function(res) {
						images.localIds = res.localIds;
						
						var i = 0; var length = images.localIds.length;

                        var upload = function() {
                            wx.uploadImage({
                                localId:images.localIds[i],
                                success: function(res) {

									images.serverId.push(res.serverId);
                                    
                                    //如果还有照片,继续上传
                                    i++;
									if (i < length) {
										upload();
									}
								}
                            });                     
						};

                        upload();
					}
				});
			}
		});

  

微信图片上传接口多图像上传(递归上传)

标签:

原文地址:http://www.cnblogs.com/chenshuo/p/4838592.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!