코드 먼저 게시
<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">'</span>; print_r(json_decode(<span>$res</span>, <span>true</span>));</span></code>').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });
위 내용은 PHP와 객체 컨텐츠를 포함한 Tencent Object Storage PHP 실습 업로드를 소개하고 있으며, PHP 튜토리얼에 관심이 있는 친구들에게 도움이 되기를 바랍니다.