title: Download MP4 Video In Specific Folder In server With CURL
body: <p>I'm Trying To Download <code>.MP4 Extension</code> File With <code>PHP Code In Specific Folder</code> My Code Working Fine For .MP4 Extension Only But I Can't Download This URL MP4 Video With This Code </p>
  
  <blockquote>
    <p><a href="https://r3---sn-vgqsrnel.c.doc-0-0-sj.sj.googleusercontent.com/videoplayback?itag=18&amp;key=yt6&amp;source=youtube&amp;mime=video%2Fmp4&amp;sparams=dur%2Cei%2Cid%2Cip%2Cipbits%2Citag%2Clmt%2Cmime%2Cmm%2Cmn%2Cms%2Cmv%2Cpl%2Cratebypass%2Csource%2Cexpire&amp;mv=m&amp;ipbits=0&amp;ratebypass=yes&amp;ms=au&amp;mn=sn-vgqsrnel&amp;pl=28&amp;mm=31&amp;dur=296.147&amp;id=o-AGGQKzVE4Kx-vQgQkb_7v_-2v8RJEP8bYukfJukhn8PM&amp;expire=1510672628&amp;lmt=1510636913694890&amp;ip=107.178.194.23&amp;mt=1510650948&amp;ei=lLQKWoz2NcruDrDrikg&amp;signature=B548DE94A6C594DE473F900D22D3A2685FBEBDED.126ED86D280FC8A4B1FF33B62A6F02EFC0E43576" rel="nofollow noreferrer">https://r3---sn-vgqsrnel.c.doc-0-0-sj.sj.googleusercontent.com/videoplayback?itag=18&amp;key=yt6&amp;source=youtube&amp;mime=video%2Fmp4&amp;sparams=dur%2Cei%2Cid%2Cip%2Cipbits%2Citag%2Clmt%2Cmime%2Cmm%2Cmn%2Cms%2Cmv%2Cpl%2Cratebypass%2Csource%2Cexpire&amp;mv=m&amp;ipbits=0&amp;ratebypass=yes&amp;ms=au&amp;mn=sn-vgqsrnel&amp;pl=28&amp;mm=31&amp;dur=296.147&amp;id=o-AGGQKzVE4Kx-vQgQkb_7v_-2v8RJEP8bYukfJukhn8PM&amp;expire=1510672628&amp;lmt=1510636913694890&amp;ip=107.178.194.23&amp;mt=1510650948&amp;ei=lLQKWoz2NcruDrDrikg&amp;signature=B548DE94A6C594DE473F900D22D3A2685FBEBDED.126ED86D280FC8A4B1FF33B62A6F02EFC0E43576</a></p>
  </blockquote>
  
  <p>I'm Trying This Code</p>
  
  <pre><code>    function download ($url, $location){
      $ch = curl_init();
      curl_setopt($ch, CURLOPT_URL, $url);
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
      curl_setopt($ch, CURLOPT_SSLVERSION,3);
      curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
      $data = curl_exec ($ch);
      $error = curl_error($ch);
      curl_close ($ch);
  
  
      $file = fopen($location, "wb");
      fwrite($file, $data);
      fclose($file);
      return 'done';
      }
      ?&gt;
      &lt;!DOCTYPE html&gt;
      &lt;html&gt;
      &lt;body&gt;
      &lt;form method="post" action="&lt;?php echo $_SERVER['PHP_SELF'];?&gt;"&gt;
      Video URL (Only With .MP4 Extension): 
      &lt;input type="text" name="url" placeholder="Video URL Here" required/&gt;&lt;br&gt;
      Video ID Number:
      &lt;input type="text" name="id" placeholder="Video ID Nmber eg:1,2,3" required/&gt;&lt;br&gt;
      &lt;input type="submit"/&gt;
      &lt;/form&gt;
      &lt;/body&gt;
      &lt;/html&gt;
      &lt;?php 
      @$url = $_POST['url'];
      @$ID = $_POST['id'];
      $SCRIPT_DIR = dirname(__FILE__);
      $TEMP_DIR = $SCRIPT_DIR . '/videos/'; 
      $location = $TEMP_DIR . $ID . '.mp4';
      if(isset($_POST['url'])){
  
          echo download($url, $location);
  
      }
  </code></pre>