2012-06-06 63 views
1

我正在使用php的serverside Youtube上传器。使用this script我将视频文件成功上传到Youtube。但是,我不想手动选择文件,但我想上传已在我的服务器上的文件。 我知道文件名/路径(并且如果这有助于以任何方式同样具有视频base64编码),并且我拥有Youtube所需的所有密钥和令牌。但是,我不知道如何将所有这些信息转换为适当的http-post。用直接文件上传替换表单输入文件

<form action="<?php echo($response->url); ?>?nexturl=<?php echo(urlencode($nexturl)); ?>" method="post" enctype="multipart/form-data"> 
    <input id="file" type="file" name="file"/> 
    <input type="hidden" name="token" value="<?php echo($response->token); ?>"/> 
    <input type="submit" value="go" /> 
</form> 

我已经尽了最大努力Digg的深入卷曲,但我不知道这是什么会帮助我在这里。

+0

我还是建议使用curl,我认为是最好的选择。 – khael

回答

0

根据你提供我想先试试这个网址找到该脚本:

$ch = curl_init($response->url."?nexturl=".urlencode($nexturl)); 
curl_setopt($ch, CURLOPT_HEADER, 0); 
curl_setopt($ch, CURLOPT_VERBOSE, 0); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER["HTTP_USER_AGENT"]); 
curl_setopt($ch, CURLOPT_POST, true); 
$post = array(
    "file"=>"@/path/to/file.avi", 
    "token"=>$response->token 
); 
curl_setopt($ch, CURLOPT_POSTFIELDS, $post); 
$response = curl_exec($ch); 
+0

谢谢khael!这是完美的解决方案! – Florian