I'm building a video converter for someone. All I need to know is, When someone pastes in a URL to a video, how can I download that video to the server? Anything here would be helpful.
Asked
Active
Viewed 92 times
1
-
Possible DUP: http://stackoverflow.com/questions/3938534/download-file-to-server-from-url – stackOverFlew Oct 26 '12 at 21:28
-
1That's not ALL you need to know. Learn about security, server post limits, reading and detecting actual videos, etc. – Anthony Hatzopoulos Oct 26 '12 at 21:28
2 Answers
2
If you want to use it in php try 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;
}

rekire
- 47,260
- 30
- 167
- 264
-
After this, how would I upload the downloaded content to the sever? – Jordan Schnur Oct 26 '12 at 21:29
-
I was expecting that you download the video on the converting server. You may need to copy the video to the converting system... But this depends on your network configuration (including operating systems). – rekire Oct 26 '12 at 21:30
-
I like it, but I need to know more. How would I copy it to the server? – Jordan Schnur Oct 26 '12 at 22:03
-
Again you need to tell us your operation system... you may can do this with the php [`copy`](http://php.net/manual/en/function.copy.php) command or with a shell command. E.g. `copy source.avi \\target-server\share` or for linux `scp source.avi user@target-server:/target/path`. But if you have trouble to copy files I'm really not sure if you are able to convert videos. This is a quiet complex topic. I know it I'm converting videos in *realtime* for a website. – rekire Oct 26 '12 at 22:06
-
The user doesn't have there operation system yet. I assume Unix. – Jordan Schnur Oct 26 '12 at 22:30
-
Also, this does not seem like it's downloading it. It just seems to echo the files contents. – Jordan Schnur Oct 26 '12 at 22:48
0
What kind of video? If you have the actual video sources then this is your best bet: download-file-to-server-from-url
If you do not, then chances are you will have to write your own video ripper such as http://keepvid.com

Community
- 1
- 1

stackOverFlew
- 1,479
- 2
- 31
- 58