Hello, I am having problems with the ftp_put() function. I can login via shell prompt.
Does anyone know why the ftp_put() function may not work? I went to the php site and followed the directions. I am connecting because I am not getting an error. I am also logging in with the username and password because I am not getting an error here as well. But so far no matter what I do, the file will not upload.
Any help with this would be great.
$query = "select Server, UserName, Password, Destination_Path, ServerType from company";
$result = @mysql_query($query);
$row = @mysql_fetch_array($result);
if (!empty($row["Server"]))
{
$hostip = gethostbyname($row["Server"]);
$conn_id = ftp_connect($hostip);
// set up basic connection
//$conn_id = ftp_connect($row["Server"]);
// login with username and password
$login_result = ftp_login($conn_id, $row["UserName"], $row["Password"]);
// check connection
if ((!$conn_id) || (!$login_result))
{
$value = "FTP connection has failed!<br>
Attempted to connect to ".$row["Server"]." for user ".$row["UserName"];
exit;
}
// IMPORTANT!!! turn passive mode on
//tried this and it did not help
//ftp_pasv ( $conn_id, true );
//parameters are ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY)
$upload = ftp_put($conn_id, $row["Destination_Path"]."/".strtolower(trim($HTTP_POST_FILES['userfile']['name'])), strtolower(trim($HTTP_POST_FILES['userfile']['name'])), FTP_BINARY);
if (!$upload)
echo $upload."<br><br>Did not upload to ftp server.";
// close the FTP stream
ftp_close($conn_id);
}
Thanks