I want to upload a video file into my server from url. Here is my code.
<?php
set_time_limit(0);
$file_name = "upload/myvideo.mp4";
$video_file_url = "http://example.com/somevideo.mp4";
file_put_contents($file_name, file_get_contents($video_file_url));
?>
Now the problem is the $video_file_url contain different type of video like .mp4, .3gp or .flv . I dont know how to get file extension from file_get_contents and $file_name always may not same what I have mentioned in my code.
Should I save this file with tmpFile.tmp name and when copied from other server just rename it with valid name and extension?