Mar*_*ark 3 php post base64 httprequest
我需要使用cURL将一些数据发布到PHP页面,并且请求包含三个参数:
我注意到Base64值在传输过程中被破坏了.
这是发送请求的代码:
$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);
Run Code Online (Sandbox Code Playgroud)
有小费吗?