POST的Base64恩在PHP codeD数据 [英] POST Base64 encoded data in PHP
本文介绍了POST的Base64恩在PHP codeD数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要张贴使用cURL一些数据到PHP页面,并且请求包含三个参数:
I need to POST some data to a PHP page using cURL, and the request contains three parameters:
- 其中两个是普通的文本值
- 一个是一个Base64连接codeD文件
我已经注意到,在传输过程中的Base64值已损坏。
I've noticed that the Base64 value is corrupted during the transmission.
这是code,它的发送请求:
This is the code that's sending the request:
$filename = "img2.jpg"; //A sample image file
$handle = fopen($filename, "r");
$data = fread($handle, filesize($filename));
$base64 = base64_encode($data);
$postData = "id=1234&sometext=asdasd&data=" . $base64;
$ch = curl_init("http://mydomain/post.php");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$httpResponse = curl_exec($ch);
curl_close($ch);
任何提示?
推荐答案
也许你应该使用的 urlen code()因为 +
和 =
在一个base64字符串?
Maybe you should use urlencode() because the +
and =
in a base64 string?
这篇关于POST的Base64恩在PHP codeD数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文