Php base64编码不同的结果

时间:2014-06-09 19:37:24

标签: php mysql base64

我有一个将脚本转换为base64的php脚本。在本地运行一切都很好,它解码和显示,但当我通过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);

1 个答案:

答案 0 :(得分:0)

$ string必须用urlencode php函数进行urlencoded