如何通过php连接到端口号为的ftps服务器?

如何通过php连接到端口号为的ftps服务器?,php,ftps,Php,Ftps,我想用PHP连接到ftps服务器。我正在使用ftp\u连接 在我的服务器URL ftp_connect'example.google.com:7080' 但我在尝试连接时收到以下警告: 警告:ftp\u connect:php\u network\u getaddresses:getaddrinfo失败:未知此类主机 现在我犯了这个错误 警告:ftp_登录:登录不正确。在第12行的C:\xampp\htdocs\service\remotedirect.php中 FTP连接失败 端口应该是第二个

我想用PHP连接到ftps服务器。我正在使用ftp\u连接

在我的服务器URL ftp_connect'example.google.com:7080'

但我在尝试连接时收到以下警告:

警告:ftp\u connect:php\u network\u getaddresses:getaddrinfo失败:未知此类主机

现在我犯了这个错误

警告:ftp_登录:登录不正确。在第12行的C:\xampp\htdocs\service\remotedirect.php中 FTP连接失败


端口应该是第二个参数。检查文件:

对于FTP,您还应使用其他功能:


你能修复这个错误吗?因为我现在无法打开我的服务器文件夹和文件。我发送代码。请检查该代码。你应该在答案中添加代码示例以改进它。只有链接的答案是非常受欢迎的,所以,即使他们去一个可靠的来源。他们总有一天会死,而答案也会变得毫无用处。@GeraldSchneider我认为如果官方文档死了,那么答案不仅会变得毫无用处,还会变成一个问题。@GBoomanikandan您的代码现在很好,我刚刚运行了它,它工作正常。仔细检查您的登录名、密码、服务器地址及其端口号。除此之外,您粘贴的代码适用于普通FTP非安全连接。登录错误应该是显而易见的。我投票将此问题视为离题,因为OP使用StackOverflow作为实时调试工具,例如,在解决了原始问题后,将问题添加到问题中。这将导致答案混乱。
  <?php

$ftp_server="example.google.com";
$ftp_port="7080";
$ftp_serusername="example";
$ftp_serpass="Pass@123";

// set up basic connection
$conn_id = ftp_connect($ftp_server,$ftp_port) or die("Couldn't connect to $ftp_server"); 

// login with username and password
//if($conn_id){
$login_result = ftp_login($conn_id, $ftp_serusername, $ftp_serpass); 
//}

// check connection
if ((!$conn_id) || (!$login_result)) { 
    echo "FTP connection has failed!";
    exit; 
}

// upload the file
//$upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY); 

// check upload status
// if (!$upload) { 
//     echo "FTP upload has failed!";
// } else {
//     echo "Uploaded $source_file to $ftp_server as $destination_file";
// }

// Retrieve directory listing
$files = ftp_nlist($conn_id, '/remote_dir');

// close the FTP stream 
ftp_close($conn_id);


?>