PHP: How do I read a .txt file from FTP server into a variable?
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 doesnt 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);
ftp_get($conn_id, $content,"/" . $_POST["path"] . "/" . "#" . $result["id"]
. " - " . $result["LastName"] . ", " . $result["FirstName"] . "/" .
$_POST["title"] . ".txt", 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 doesnt 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?
Thanks
No comments:
Post a Comment