2016-01-29 13:23
浏览 202


I am trying to set up FTP SSL connection in PHP. I have used ftp_connect() fine and works great. As soon as I try to use ftp_ssl_connect(), I get this error:

Fatal error: Call to undefined function ftp_ssl_connect()

I do have openssl extension turned on in PHP extentions. I am not sure what else there is to do as searching google there is nothing that I can find to do to make this function call work. Does anyone know when what I am missing or to check to see if something else needs to be installed on my wampserver?

Here is my php code I am using:

$conn_id = ftp_ssl_connect($ftp_server); 
$ftp_user_name = "username"; 
$ftp_user_pass = "password"; 
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); 

ftp_pasv($conn_id, true); 
if ((!$conn_id) || (!$login_result)) { 
    echo "FTP connection has failed!"; 
    echo "Attempted to connect to $ftp_server for user $ftp_user_name"; 
} else { 
    echo "Connected to $ftp_server, for user $ftp_user_name"; 

It obviously doesn't get past the first line because of saying that ftp_ssl_connect() is an undefined function.

图片转代码服务由CSDN问答提供 功能建议

我正在尝试在PHP中设置FTP SSL连接。 我已经使用 ftp_connect()了,效果很好。 一旦我尝试使用 ftp_ssl_connect(),我就会收到此错误:

致命错误:调用未定义的函数ftp_ssl_connect()< / p>

我确实在PHP扩展中打开了openssl扩展。 我不知道还有什么可以做,因为搜索谷歌没有什么我可以找到做这个函数调用工作。 有谁知道我什么时候缺少或检查是否需要在我的wampserver上安装其他东西?


  $ conn_id = ftp_ssl_connect($ ftp_server);  
 $ ftp_user_name =“username”;  
 $ ftp_user_pass =“密码”;  
 $ login_result = ftp_login($ conn_id,$ ftp_user_name,$ ftp_user_pass);  
ftp_pasv($ conn_id,true);  
if((!$ conn_id)||(!$ login_result)){
 echo“尝试连接到$ ftp_server以获取用户$ ftp_user_name”;  
} else {
 echo“已连接到$ ftp_server,对于用户$ ftp_user_name”;  

由于 ftp_ssl_connect()是一个未定义的函数,它显然没有越过第一行。

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • duan19913 2016-01-29 13:28

    From PHP Documentation:

    Note: Why this function may not exist ftp_ssl_connect() is only available if both the ftp module and the OpenSSL support is built statically into php, this means that on Windows this function will be undefined in the official PHP builds. To make this function available on Windows you must compile your own PHP binaries.

    Note: ftp_ssl_connect() is not intended for use with sFTP. To use sFTP with PHP, please see ssh2_sftp().

    (BTW: I don't use Windows but I can't access to ftp_ssl_connect())

    打赏 评论

相关推荐 更多相似问题