首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >从URL上传内容

从URL上传内容
EN

Stack Overflow用户
提问于 2012-10-27 05:22:15
回答 2查看 87关注 0票数 1

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

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2012-10-27 05:25:02

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

代码语言:javascript
复制
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]

票数 2
EN

Stack Overflow用户

发布于 2012-10-27 05:28:16

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

如果您不这样做,那么很有可能您将不得不编写自己的视频解析器,如http://keepvid.com

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13094609

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档