Hello,
I created this PHP script (actually it came from my textbook). It apparently connects to the FTP site okay, but I cannot log on. The user name and password have been double-checked for typos, but for security reasons I cannot put them up here, so I just put "host.com", "user_name" and "password" here.
Is there anything I can add to this script that will allow me to see exactly why the user name is not being accepted?PHP Code:
<html>
<head>
<title>LSR FTP Script</title>
</head>
<body>
<h1>LSR FTP Script</h1>
<?php
// set up variables
$host = 'host.com';
$user = 'user_name';
$password = 'password';
$remotefile = 'addendums.txt.gz';
$localfile = 'addendums.txt.gz';
// connect to host
$conn = ftp_connect("$host");
if (!$conn)
{
echo 'Error: Could not connect to ftp server<br />';
exit;
}
echo "Connected to $host.<br />";
// log in to host
$result = ftp_login($conn, $user, $pass);
if (!$result)
{
echo "Error: Could not log on as $user<br />";
ftp_quit($conn);
exit;
}
echo "Logged in as $user<br />";
echo 'Getting file from server...<br />';
$fp = fopen ($localfile, 'w');
if (!$success = ftp_fget($conn, $fp, $remotefile, FTP_BINARY))
{
echo 'Error: Could not download file';
ftp_quit($conn);
exit;
}
fclose($fp);
echo 'File downloaded successfully';
// close connection to host
ftp_quit($conn);
?>
</body>
</html>
Also, if I use my browser to FTP to the FTP site, I CAN enter my user name and password, and can get into the FTP site fine.
The messages I receive when I attempt to connect to the FTP site using my PHP script are as follows:
-----
Connected to idx.fnismls.com..
Error: Could not log on as user_name
-----
Thanks in advance!
Miaow


Reply With Quote


Bookmarks