title: php ftp_get() returns permission denied
body: <p>I'm using a ftp upload script to transfer one server to another. It works fine in a browser window, and works great from an ssh command line by running:
  php  /var/www/vhosts/domain.com/httpdocs/ftp_shell.php</p>
  
  <p>but when I run the exact same command from a cron, I get this:</p>
  
  <p>PHP Warning:  ftp_get(ftp.tmp): failed to open stream: Permission denied in /var/www/vhosts/domain.com/httpdocs/ftp_shell.php on line 516
  PHP Warning:  ftp_get(): Error opening ftp.tmp in /var/www/vhosts/domain.com/httpdocs/ftp_shell.php on line 516</p>
  
  <p>I looked on line 516, which is:</p>
  
  <pre><code>    if((ftp_get($ftp_from,"ftp".$tmp.".tmp",$fname,FTP_BINARY) ||
          ftp_get($ftp_from,"ftp".$tmp.".tmp",$fname,FTP_ASCII)) &amp;&amp;
         (ftp_put($ftp_to,$fname,"ftp".$tmp.".tmp",FTP_BINARY) ||
          ftp_put($ftp_to,$fname,"ftp".$tmp.".tmp",FTP_ASCII)) &amp;&amp;
         ftp_site($ftp_to,"chmod ".base_convert($chmod,10,8)." $fname") &amp;&amp;
         f_size()&amp;&amp;unlink("ftp".$tmp.".tmp")) {echoout(" (".$size_b." bytes) ok&lt;br&gt;");$count_f++;}
  </code></pre>
  
  <p>I know that it's writing the file to a temp file, but why would it allow me to do it in the browser and command line, but not a cron?</p>