如何在PHP FTP中包含端口

如何在PHP FTP中包含端口,php,ftp,Php,Ftp,我想用FTP从我的新服务器上传一个文件 新服务器不使用默认端口21,而是使用8821,我的FTP有一些问题。所以我想这可能就是问题所在 如何在我当前的脚本中包含端口,或者根本不需要它 $logfile = $_GET['logfile']; $currentlog = "$logfile"; $ftp_usernameb = 'username'; $ftp_userpassb = 'pass'; $ftp_serverb = "host"; $ftp_connb = ftp_connect($

我想用FTP从我的新服务器上传一个文件

新服务器不使用默认端口
21
,而是使用
8821
,我的FTP有一些问题。所以我想这可能就是问题所在

如何在我当前的脚本中包含端口,或者根本不需要它

$logfile = $_GET['logfile'];
$currentlog = "$logfile";
$ftp_usernameb = 'username';
$ftp_userpassb = 'pass';
$ftp_serverb = "host";
$ftp_connb = ftp_connect($ftp_serverb) or die("Could not connect to $ftp_serverb");
$loginb = ftp_login($ftp_connb, $ftp_usernameb, $ftp_userpassb);
$local_fileb = "$currentlog";
$server_fileb = "/188.40.46.30:7800/".$currentlog."";

// download server file
if (ftp_get($ftp_connb, $local_fileb, $server_fileb, FTP_ASCII))
{
//Downloaded continue with script
?>
<font color="green"><b>The logs have been updated succesfully!</b></font>
<meta http-equiv="refresh" content="0; url=?action=done&logfile=<?php echo $_GET['logfile']; ?>&search=<?php echo $_GET['search']; ?>" />
<?php
}
else
{
?>
<font color="red"><b>Couldn't update logs, contact Jesse!</b></font>
<meta http-equiv="refresh" content="0; url=?action=failed&logfile=<?php echo $_GET['logfile']; ?>&search=<?php echo $_GET['search']; ?>" />
<?php
exit;
}
// close connection
ftp_close($ftp_connb);
$logfile=$\u GET['logfile'];
$currentlog=“$logfile”;
$ftp_usernameb='username';
$ftp_userpassb='pass';
$ftp\u serverb=“主机”;
$ftp_connb=ftp_connect($ftp_serverb)或die(“无法连接到$ftp_serverb”);
$loginb=ftp\u login($ftp\u connb,$ftp\u usernameb,$ftp\u userpassb);
$local_fileb=“$currentlog”;
$server_fileb=“/188.40.46.30:7800/”$currentlog。”;
//下载服务器文件
if(ftp_get($ftp_connb,$local_fileb,$server_fileb,ftp_ASCII))
{
//下载并继续使用脚本
?>
日志已成功更新!

在手册页面中查看以下内容:

现在,您所要做的就是通过更改

$ftp_connb = ftp_connect($ftp_serverb) or die("Could not connect to $ftp_serverb");


来吧,伙计们!发布一个答案:3
$ftp_connb = ftp_connect($ftp_serverb) or die("Could not connect to $ftp_serverb");
$port_number = 8821;
$ftp_connb   = ftp_connect($ftp_serverb, $port_number) or die("Could not connect to $ftp_serverb");