dousu1916 2013-06-17 15:43
浏览 47
已采纳

检索项目时PHP超时

I'm trying to get a directory listing from a FTP server which only accepts FTP connections over explicit TLS.

<?php
$ftp_server = "...";
$ftp_user_name = "...";
$ftp_user_pass = "...";

// set up basic ssl connection
$conn_id = ftp_ssl_connect($ftp_server);

// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
echo $login_result . "<br/>";

// change dir to "data"
$chdir_result = ftp_chdir($conn_id, "data");
echo $chdir_result . "<br/>";
echo ftp_pwd($conn_id) . "<br/>"; 

// get contents of the current directory
$contents = ftp_rawlist($conn_id, ".");

// output $contents
var_dump($contents);

// close the ssl connection
ftp_close($conn_id);
?>

The script hangs for about a minute and gives the following output:

 1
 1
 /data
 bool(false)

I also tried using ftp_nlist and print_r with no avail. (print_r just prints blank).

  • 写回答

1条回答 默认 最新

  • dragon071111 2013-06-17 16:15
    关注

    If you have a firewall or NAT enabled on your server then you have to use passive mode for your ftp connection

    Add this before ftp_rawlist()

    ftp_pasv( $conn_id, true );
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 delta降尺度方法,未来数据怎么降尺度
  • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效
  • ¥15 高德地图点聚合中Marker的位置无法实时更新
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错