[英]Php base64 encode different results
我有一个PHP脚本,可将图像转换为base64。 在本地运行一切都很好,它可以解码并显示,但是当我通过curl post将其发送到mysql时,它会生成一个不同的字符串。 字符串的前1/4匹配,然后全部更改。 我已经搜索了几个小时,但是如果有人可以帮助,还是没有一个明智的选择?
$newImg = "Path to image";
$imgBinary = fread(fopen($newImg, "r"), filesize($newImg));
$imgString = base64_encode($imgBinary);
$string = "FName=SName= etc etc etc Photo=".$imgString;
$url ="Url to web service";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec ($ch);
$phpArray = json_decode($output, true);
curl_close ($ch);
$ string必须使用urlencode php函数进行urlencoded
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.