gpt4 book ai didi

php - 从 URL 上传内容

转载 作者:行者123 更新时间:2023-12-04 22:56:26 26 4
gpt4 key购买 nike

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

最佳答案

如果您想在 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]

关于php - 从 URL 上传内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13094609/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com