CodeIgniter Forums
Curl - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Curl (/thread-52287.html)



Curl - El Forum - 06-05-2012

[eluser]Unknown[/eluser]
hello
i want to get video from URL and save it in folder
this is the sample of URL

url="http://vod.cms.download.performgroup.com/omnisport/ready/french/162/fr-050612-ireland_1338883384151_162.m4v"

how i can do that

please if anyone can help me
thanks for all






Curl - El Forum - 06-05-2012

[eluser]Cristian Gilè[/eluser]
Add the following method to your controller (or library or helper):

Code:
function get_video_from_url($link)
{  
    $ch = curl_init();  
    curl_setopt($ch, CURLOPT_POST, 0);
    curl_setopt($ch,CURLOPT_URL,$link);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $result=curl_exec($ch);
    curl_close($ch);
    return $result;
}

call the new method and save the file locally:

Code:
$video = $this->get_video_from_url("http://vod.cms.download.performgroup.com/omnisport/ready/french/162/fr-050612-ireland_1338883384151_162.m4v");

if ( ! write_file('./video.m4v', $video))
{
    echo 'Unable to write the file';
}
else
{
    echo 'File written!';
}



Curl - El Forum - 06-05-2012

[eluser]Sanjay Sarvaiya[/eluser]

Code:
copy ( $source , $dest);
further more information read http://www.php.net/copy/


Curl - El Forum - 06-05-2012

[eluser]Unknown[/eluser]
thanks all

i try Cristian Gilè code and it's work Smile thanks