1
我試圖從本地服務器上傳視頻到youtube.com。使用curl將視頻上傳到youtube
如果我使用下面的表格,視頻將被上傳到YouTube。我可以在登錄後從YouTube獲取響應,並採用下面的表單中的響應。
<form action="<?php echo($response->url); ?>?nexturl=<?php echo(urlencode($nexturl)); ?>" method="post" enctype="multipart/form-data">
<p class="block">
<label>Upload Video</label>
<span class="youtube-input">
<input id="file" type="file" name="file" />
</span>
</p>
<input type="hidden" name="token" value="<?php echo($response->token); ?>"/>
<input type="submit" value="Upload Video" />
</form>
但是,如果試圖做同樣的捲曲如下那麼它不工作..任何建議?
$file_name_with_full_path = $video_path; //$video_path is like /path/to/abc.mp4
$post = array('file'=>'@'.$file_name_with_full_path, 'token' => $response->token,);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$response->url."?nexturl=".urlencode($nexturl));
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
$result=curl_exec ($ch);
curl_close ($ch);
echo $result;
die();
請使用盡可能多的相關標籤儘可能在未來 – Sheena
olrite!謝謝 。 Neway謝謝我使用了Zend,現在它解決了。 – user1782952