本地储存限制10M,picker显示内容不全##微信小程序教程。这我知道,但是只保存了一张照片还是压缩的,隔了两小时等上传时就没啦,图片也空白!悲哀,请问微信是否有自动清除的功能
wx.chooseImage({
sizeType: ['compressed'],
sourceType: ['camera'],
success: function (res) {
var tempFilePaths = res.tempFilePaths;
wx.saveFile({
tempFilePath: tempFilePaths[0],
success: function (res) {
console.log(res)
var savedFilePath = res.savedFilePath;
that.setData({//保存图片数据
isnew: false,
files: that.data.files.concat(savedFilePath),
imgadd: that.data.imgadd.concat(that.data.ladd),
imgtime: that.data.imgtime.concat(time)
});
}
})
}
})
app.uploadImg({
url: 'https://*****',//
path: pics,//这里是选取的图片的地址数组
imgadd:this.data.imgadd,//每张图片的地址
imgtime:this.data.imgtime,//每张图片的拍照时间
keys:keys,
userkey:this.data.userkey,
times:this.data.times,
stype:''
});
wx.uploadFile({
url: data.url,
filePath: data.path[i],
name: 'img',
formData: {
'keys':data.keys,
'username':data.username,
'userkey':data.userkey,
'iclass':data.iclass
},
success: (resp) => {
success++;
console.log(resp.data);
console.log('success'+i);
},
fail: (res) => {
fail++;//图片上传失败,图片上传失败的变量+1
console.log(res)
console.log('fail:' + i + "fail:" + fail);
},
complete: () => {
i++;//这个图片执行完上传后,开始上传下一张
console.log("i的值" + i + ",data.path.length" + data.path.length);
if (i == data.path.length) { //当图片传完时,停止调用
wx.hideLoading();
that.tDones("上传完成")
that.delSaveImg({//上传完成后删除文件和保存信息
'keys':data.keys,
'files': data.path
})
console.log('成功:' + success + " 失败:" + fail);
} else {//继续
console.log(i);
wx.hideLoading();
data.i = i;
data.success = success;
data.fail = fail;
that.uploadImg(data);
}
}
});
本文网址:http://www.91bianli.com/kaifazhinan/69969.html