我看了很多博文,关于微信小程序和PHP通信的文章,但试了很久仍无法解决,哪位帮指点一下,不胜感激
微信:
//小程序代码
openCamera:function(){
var that = this
wx.chooseImage({
count: 1,
sizeType:['original','compressed'],
sourceType:['album','camera'],
success:function(res)
{
var tempFilePaths = res.tempFilePaths
that.setData({
src:tempFilePaths
})
wx.uploadFile({
filePath: tempFilePaths[0],
header: {
"Content-Type": "multipart/form-data"
},
name: 'uploadfile_ante',
url: 'https://364***20.goho.co/php/2021-01/xunchang/receivImg.php',
formData:null
})
}
})
}
//后台PHP代码
<?PHP
$f=$_FILES['file'];
$FILENAME="a123.jpg";
move_uploaded_file($f['tmp_name'],$FILENAME);
echo 1;
?>
//小程序配置