[英]How do I connect to ftps server with port number through php?
我想用 PHP 連接到 ftps 服務器。 我正在使用ftp_connect()
在我的 ServerURL ftp_connect('example.google.com:7080')
但是當我嘗試連接時收到此警告:
警告:ftp_connect(): php_network_getaddresses: getaddrinfo failed: No such host is known
<?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);
?>
現在我收到了這個錯誤
警告:ftp_login():登錄不正確。 在 C:\\xampp\\htdocs\\serve\\remotedirect.php 中第 12 行 FTP 連接失敗!
端口應該是第二個參數。 檢查文檔:
https://www.php.net/manual/en/function.ftp-connect.php
https://www.php.net/manual/en/function.ftp-login.php
同樣對於 FTPS,您應該使用其他功能:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.