从URL上传内容

时间:2012-10-26 21:22:15

标签: php ffmpeg

我正在为某人制作视频转换器。我需要知道的是,当某人粘贴到视频的URL时,如何将该视频下载到服务器?这里的任何内容都会有所帮助。

2 个答案:

答案 0 :(得分:2)

如果你想在php中使用它,试试curl:

function curl_download($Url){

    // is cURL installed yet?
    if (!function_exists('curl_init')){
        die('Sorry cURL is not installed!');
    }

    // OK cool - then let's create a new cURL resource handle
    $ch = curl_init();

    // Now set some options (most are optional)

    // Set URL to download
    curl_setopt($ch, CURLOPT_URL, $Url);

    // Set a referer
    curl_setopt($ch, CURLOPT_REFERER, "http://www.example.org/yay.htm");

    // User agent
    curl_setopt($ch, CURLOPT_USERAGENT, "MozillaXYZ/1.0");

    // Include header in result? (0 = yes, 1 = no)
    curl_setopt($ch, CURLOPT_HEADER, 0);

    // Should cURL return or print out the data? (true = return, false = print)
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

    // Timeout in seconds
    curl_setopt($ch, CURLOPT_TIMEOUT, 10);

    // Download the given URL, and return output
    $output = curl_exec($ch);

    // Close the cURL resource, and free system resources
    curl_close($ch);

    return $output;
}

[Source]

答案 1 :(得分:0)

什么样的视频?如果你有实际的视频源,那么这是你最好的选择: download-file-to-server-from-url

如果你不这样做,那么你可能需要编写自己的视频开膛手,例如http://keepvid.com