最初にコードを投稿してください
<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>
上記では、PHP とオブジェクトのコンテンツを含む Tencent Object Storage の PHP 実践のアップロードについて紹介しました。PHP チュートリアルに興味のある友人に役立つことを願っています。