时间:2021-07-01 10:21:17 帮助过:40人阅读
uploadToken($bucket, null, 3600);//获取上传所需的token
function request_by_curl($remote_server,$post_string,$upToken) {
$headers = array();
$headers[] = 'Content-Type:image/png';
$headers[] = 'Authorization:UpToken '.$upToken;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$remote_server);
//curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER ,$headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
//curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_string);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
$str="base64编码的字符串";
echo "";
echo request_by_curl('http://upload.qiniu.com/putb64/-1',$str,$upToken);
echo "
";
成功get。
以上就介绍了php向七牛上传base64编码的图片,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。