Php read file from ftp server

I have two servers. I already have a .txt file in the one I'm connecting to.

I need to get the .txt file contents and put them into a $ variable. Here is my code that doesn't work:

$ftp_server = $_POST["site"];
$path = $_POST["path"];
$ftp_user_name = $_POST["username"];
$ftp_user_pass = $_POST["pass"];

// 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 =
    "/" . $_POST["path"] . "/" . "#" . $result["id"]
    . " - " .    $result["LastName"] . ", " . $result["FirstName"]
    . "/" . $_POST["title"] . ".txt";
ftp_get($conn_id, $content, $remote_filename, FTP_ASCII);

This code connects to the FTP and I used the ftp_get to copy from one text file to a variable called $content. 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.

Is there a way to do this with the PHP FTP functions?

Now, when I try this:

$fileContents = file_get_contents('ftp://username:pa‌​ssword@hostname/path/to/file');

It gives an error:

Warning: fopen(ftp:///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

Why am I getting this error?

Thanks again

How to read files from ftp in php?

The file_get_contents is the easiest solution: $contents = file_get_contents('ftp://username:pa‌​ssword@hostname/path/to/file');

How do I get files from an FTP?

How to Copy Files From a Remote System ( ftp ).
Change to a directory on the local system where you want the files from the remote system to be copied. ... .
Establish an ftp connection. ... .
Change to the source directory. ... .
Ensure that you have read permission for the source files. ... .
Set the transfer type to binary..

How do I read an FTP server?

After you log in to the server, you can upload a file to or download a file from the authorized directory by following these steps: Use the dir or ls command to display the directory and location of the file on the FTP server. ... Working with files on the FTP server..

What is FTP server in PHP?

PHP FTP Introduction The FTP functions give client access to file servers through the File Transfer Protocol (FTP). The FTP functions are used to open, login and close connections, as well as upload, download, rename, delete, and get information on files from file servers.