gpt4 book ai didi

php - PHP 中的 FTP 被动模式

转载 作者:行者123 更新时间:2023-12-03 08:58:36 27 4
gpt4 key购买 nike

需要在 PHP 文件中以被动模式设置 FTP 连接。

当我的连接详细信息如下时,不知道该怎么做:

protected $_credentials = array (
'host' => 'xxx.xxx.xxx.xxx',
'user' => 'xxxxx',
'password' => 'xxxxx',
'timeout' => '10'
);

如何在上面添加被动模式?

最佳答案

假设您使用 built-in PHP FTP functions (ftp_*),使用ftp_pasv function ,例如:

$conn_id = ftp_connect($host) or die("Unable to connect to host");

ftp_login($conn_id, $user, $password) or die("Authorization failed");

// turn passive mode on
ftp_pasv($conn_id, true) or die("Unable switch to passive mode");

您的代码示例仅创建关联数组。它实际上并没有做任何“FTP”。因此,如果您使用不同的 PHP FTP 库,您必须告诉我们。

关于php - PHP 中的 FTP 被动模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52950285/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com