代码:
$data = $_REQUEST['data'];
$curl = curl_init();
$data = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABYAAAAeCAYAAAAo5+5WAAAAwUlEQVRIie2UwQkCMRBFf8RSdj2IFWQrMCdPlpA0YRHZqyV42lPSiLfYy5i4oIhEJ0pAdD/M7fP4Gf5EUBQqaFYDOoG/AOyNgBC36frT5+AEHTaE1MZxAraHFsYzyVSiYElqx7KW7bhZYMW0loH9gOOyZVnnBVQYBeyo4dlZC3M6/ieaeNsd9TJxaoeCiwHW/Mc9TxzIShCzBA/Kgp2WZMN70Dy4oK855eu2V3fnfJ2uB+ewxSV2Bf3YtzmBJ/C/g88GTM7oHPlgrAAAAABJRU5ErkJggg==";
curl_setopt_array($curl, array(
CURLOPT_URL => "http://domain.com",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_POSTFIELDS => "type=webimage&image={$data}",
CURLOPT_HTTPHEADER => array(
"content-type: application/x-www-form-urlencoded"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
但是服务端接收数据不全,导致Base64编码的图片无法解析。
梵蒂冈之花