您好,欢迎访问一九零五行业门户网

php向七牛上传base64编码的图片

最近一直在研究如何通过php向七牛云存储上传base64编码的图片,求助百度,谷歌都没有找到答案,无奈只能自己研究,元旦还在敲代码也算是够狠的,值得高兴的是成功解决了该问题,与大家分享一下我的代码:
uploadtoken($bucket, null, 3600);//获取上传所需的tokenfunction 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教程有兴趣的朋友有所帮助。
其它类似信息

推荐信息