title: two codes Theoreticaly same but practicaly works different...how is it possible
body: <p><strong>getaudio.php</strong> <em>version 1</em></p>
  
  <pre><code>&lt;?php
      $youtubeUrl =  $_GET['url'];
      $content = shell_exec("youtube-dl -j $youtubeUrl "); 
      $meta=json_decode($content);  
      $file= $meta-&gt;{'_filename'};
      $fileWithoutExtension = explode(".",$file)[0];
      $extension = ".m4a";
      $file = $fileWithoutExtension . $extension;   
  
      header("Content-Disposition: attachment; filename=\"$file\"" );
      header("Content-Type: application/octet-stream");
  
      passthru("youtube-dl -f 140 -o - $youtubeUrl");     
  ?&gt;
  </code></pre>
  
  <p><strong>getaudio.php</strong> <em>version 2</em></p>
  
  <pre><code>&lt;?php
      $youtubeUrl =  $_GET['url'];
      $file = shell_exec("youtube-dl -f 140 --get-filename $youtubeUrl "); 
  
      header("Content-Disposition: attachment; filename=\"$file\"" );
      header("Content-Type: application/octet-stream");
  
      passthru("youtube-dl -f 140 -o - $youtubeUrl");
  ?&gt;
  </code></pre>
  
  <hr>
  
  <p>if 
  <strong>url</strong> = <a href="https://www.youtube.com/watch?v=bvYtKY-UMxA" rel="nofollow">https://www.youtube.com/watch?v=bvYtKY-UMxA</a> then we get <strong>$file</strong> =
  Deewana Kar Raha Hai Full Song 1080p HD Raaz 3 2012   YouTube-bvYtKY-UMxA.m4a</p>
  
  <p>my question is <strong>getaudio.php version 1</strong> is working fine but <strong>getaudio.php version 2</strong> isn't....</p>
  
  <p><strong>getaudio.php version 2</strong> is downloading but the file is coruppted....</p>
  
  <hr>
  
  <p>when <strong>$file</strong> is same for both php files then how is it possible that the second one is not working</p>
  
  <hr>
  
  <p>HINT: download <strong>youtube-dl.exe</strong>(for windows) &amp; <strong>place</strong> it with the <strong>two php</strong> files &amp; run in localhost</p>