gpt4 book ai didi

PHP base64编码不同的结果

转载 作者:行者123 更新时间:2023-11-30 00:10:13 29 4
gpt4 key购买 nike

我有一个将图像转换为 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);

最佳答案

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

关于PHP base64编码不同的结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24127635/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com