title: PHP: How do I read a .txt file from FTP server into a variable?
body: <p>I have two servers. I already have a .txt file in the one I'm connecting to.</p>
  <p>I need to get the .txt file contents and put them into a <code>$</code> variable. Here is my code that doesn't work:</p>
  <pre><code>$ftp_server = $_POST[&quot;site&quot;];
  $path = $_POST[&quot;path&quot;];
  $ftp_user_name = $_POST[&quot;username&quot;];
  $ftp_user_pass = $_POST[&quot;pass&quot;];
  
  // set up basic connection
  $conn_id = ftp_connect($ftp_server);
  
  // login with username and password
  $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
  
  $remote_filename =
      &quot;/&quot; . $_POST[&quot;path&quot;] . &quot;/&quot; . &quot;#&quot; . $result[&quot;id&quot;]
      . &quot; - &quot; .    $result[&quot;LastName&quot;] . &quot;, &quot; . $result[&quot;FirstName&quot;]
      . &quot;/&quot; . $_POST[&quot;title&quot;] . &quot;.txt&quot;;
  ftp_get($conn_id, $content, $remote_filename, FTP_ASCII);
  </code></pre>
  <p>This code connects to the FTP and I used the <code>ftp_get</code> to copy from one text file to a variable called <code>$content</code>. I know a variable doesn't belong in this parameter, but I'm sold right now. I have no idea how to read this .txt file.</p>
  <p>Is there a way to do this with the PHP FTP functions?</p>
  <p>Now, when I try this:</p>
  <pre><code>$fileContents = file_get_contents('ftp://username:pa‌​ssword@hostname/path/to/file');
  </code></pre>
  <p>It gives an error:</p>
  <blockquote>
  <p>Warning: fopen(ftp://...@goldenbooklet.com/101Notebook Backup: 22-08-2013/#11 - Cappucci, Ryan/queen.txt) [function.fopen]: failed to open stream: FTP server reports 550 /101Notebook Backup: 22-08-2013/: not a regular file in /home/content/34/11614434/html/adminpdo.php on line 269</p>
  </blockquote>
  <p>Why am I getting this error?</p>
  <p>Thanks again</p>