// 點擊瀏覽
showImage(){
wx.previewImage({
current: '', // 當前顯示圖片路徑
urls: [this.data.filePath] // 需要預覽圖片的路徑
})
},
//上傳文件
upload_data(){
var filePath = this.data.filePath
wx.getImageInfo({
src: filePath,
success: function (res) {
console.log(res.width)
console.log(res.height)
if (res.width != 600 && res.height !=900){
console.log('圖片大小非600*900')
}
else{
console.log('準備上傳...')
wx.uploadFile({
url: 'http://example.weixin.qq.com/upload', //接口地址
filePath: filePath,//文件路徑
name: 'file',//文件名,不要修改,Flask直接讀取
formData: {
'user': 'test'
}, // 其他表單數據,如地理位置、標題、內容介紹等
success: function (res) {
var data = res.data
console.log('上傳成功...')
}
})
}
}
})
},
|