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

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

		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();
					}
				});
			}
		});

  

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

上一篇:CPP通过JNI调用JAVA函数Demo


下一篇:杭电ACM1016解题报告(Java)