H5+实现保存图片到本地相册

			//保存到本地
			$('#savePic').click(function(){
                //imgUrl 图片网络路径
				var timestamp = (new Date()).valueOf();
				var downLoader = plus.downloader.createDownload(imgUrl, {
				    method: 'GET',
				    filename: '_downloads/image/' + timestamp + '.png'
				}, function(download, status) {
					if(status==200){
						var fileName = download.filename;
						/**
						 * 保存至本地相册
						 */
						plus.gallery.save(fileName, function() {
						    mui.toast("保存成功");	
						},function(){
							 mui.toast("保存失败,请重试");	
						});
					}else{
						 mui.toast("下载失败,请重试");	
					}
				});
				 downLoader.start();
			})

 

你可能感兴趣的:(hbuilder)