title: PHP cURL download does not work when called from browser
body: <p>I want a php script which I can access from browser and that script will download files to my remote server (not to my computer). 
  This is complete code which I call from browser as localhost/download.php but it does not work (in network manager I see that something is being downloaded but in project folder I can not find it):</p>
  
  <pre><code>&lt;?  
      function download($url, $referer, $name)
      {
          $path = $name.'.mp3';
          $fp = fopen($path, 'w');
          $ch = curl_init($url);
          curl_setopt($ch, CURLOPT_FILE, $fp);
          curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
          curl_setopt($ch, CURLOPT_HEADER, false);
          curl_setopt($ch, CURLOPT_HTTPHEADER, array(
                      'User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:13.5) Gecko/20100101 Firefox/13.4.9\r\n',
                      "Referer: $referer" 
          ));
          $data = curl_exec($ch);
          curl_close($ch);
          fwrite($fp, $data);
          fclose($fp);
      }
  
      echo 'Please wait it is downloading...&lt;br/&gt;';
      /*$url = $_GET['url'];
      $referer = $_GET['referer'];
      $name = $_GET['name'];*/
      $url = "http://stream.get-tune.net/file/91259796/101538464/3652118538/ee58ddeb905ffa12/Palwan_Halmyradow_-_Sensiz_(get-tune.net).mp3";
      $referer = "http://get-tune.net/?a=music&amp;q=palwan+halmyradow";
      $name = "Palwan Halmyradow - Sensiz";
      download($url, $referer, $name);
  ?&gt;
  </code></pre>
  
  <p>But it works when I call below command from command line:</p>
  
  <pre><code>php /var/www/idym/download.php
  </code></pre>
  
  <p>What is the problem?</p>