贴代码先
<code><span><?php </span><span>$file_name</span> = <span>'test.jpg'</span>; <span>$upload_url</span> = <span>'web.file.myqcloud.com/files/v1/10039609/wechat/cover/'</span> . <span>$file_name</span>; <span>$exp</span> = time() + <span>600</span>; <span>$sign</span> = <span>'a=10039609&b=wechat&k=AKIDqybsVwxcwSeGYJTsLElPdjgFGa5aPGso&e='</span> . <span>$exp</span> . <span>'&t='</span> . time() . <span>'&r='</span> . rand() . <span>'&f=/10039609/wechat/cover/'</span> . <span>$file_name</span>; <span>$sign</span> = base64_encode(hash_hmac(<span>'SHA1'</span>, <span>$sign</span>, <span>'prbaqNGhrNinShbRWXqfT10wpCFs68hu'</span>, <span>true</span>) . <span>$sign</span>); <span>$post_data</span> = [ <span>'op'</span> => <span>'upload'</span>, <span>'filecontent'</span> => file_get_contents(<span>'https://ss0.bdstatic.com/5aV1bjqh_Q23odCf/static/superman/img/logo_top_ca79a146.png'</span>), <span>// baidu logo</span>]; <span>$header</span> = [ <span>'Content-Type: multipart/form-data'</span>, <span>'Authorization: '</span> . <span>$sign</span>, ]; <span>$ch</span> = curl_init(<span>$upload_url</span>); curl_setopt(<span>$ch</span>, CURLOPT_POST, <span>1</span>); curl_setopt(<span>$ch</span>, CURLOPT_HTTPHEADER, <span>$header</span>); curl_setopt(<span>$ch</span>, CURLOPT_RETURNTRANSFER, <span>1</span>); curl_setopt(<span>$ch</span>, CURLOPT_POSTFIELDS, <span>$post_data</span>); <span>$res</span> = curl_exec(<span>$ch</span>); <span>echo</span><span>'<pre class="brush:php;toolbar:false">'; print_r(json_decode($res, true));').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });
以上就介绍了腾讯对象存储PHP实践之上传,包括了php,对象方面的内容,希望对PHP教程有兴趣的朋友有所帮助。