python Post 数据 PHP 接收保存
python端 读取文件post base64格式的数据
import base64
import urllib
import requests
name="KMjjTas.jpg"
f = open(name, 'rb')
img =base64.b64encode(f.read())
res = requests.post(url="http://www.xxxx.com/index.php?name="+name, data=img)
print(res.text)
php端 接收post base64格式数据解码 保存
<?php
$postStr = file_get_contents("php://input");
$name=$_REQUEST['name'];
$decodedData = base64_decode($postStr);
file_put_contents('tmp/'.$name,$decodedData);
echo "write ok";
?>