我写了一些访问FTP服务器并下载平面文件的代码。它可以在我的WAMP (Windows5.3.10)开发环境中工作,但在生产服务器(5.3.2 - Linux)上调用ftp_nlist时会失败。
它在那里停留了大约30秒,然后死了,并显示了编码错误消息[FTP] Unable to retrieve files in the directory。
相关代码如下:
$link = ftp_connect(constant("FTP_SERVER"));
if(!$link)
die("Unable to open connection to FTP Server:
我正在寻找选项列表,它可以在方法ftp_nlist和ftp_rawlist之前目录中的PHP模块FTP中使用。下面是我发现的一些例子:
// include hidden files
ftp_rawlist($h, '-a /');
// more complex - only names of files
ftp_rawlist($h, '-1l /');
也许它是特定于FTP服务器的,但两者都可以在Windows和Linux上工作。我有任何规格和完整的清单.
如何获取服务器上的文件名列表/数组(不带扩展名)。我只想要文件名(curl或ftp也可以)。
我已经尝试了ftp_nlist和curl_getinfo,但是输出并不像预期的那样。
// connect and login to FTP server
$ftp_server = "user.com";
$ftp_username = "user";
$ftp_userpass = "demo";
$ftp_conn = ftp_connect($ftp_server) or die("Could not connect to
$ftp_
<?
//$conn_id = ftp_connect($_GET['host'],21,5) or die ('Cant connect to host!');
$conn_id = ftp_connect($_GET['host']) or die ('Cant connect to host!');
ftp_pasv($conn_id, true);
echo 'host OK<br>';
$login_result = ftp_login($conn_id, addslashes
我有FTP和我需要列出所有文件在FTP上传目录和点击任何列出的文件,它将从FTP下载特定的文件。
它列出了上传目录中的文件,但当我尝试下载文件时,它会键入"no file“。
我的代码:
// connect and login to FTP server
$ftp_server = "IP";
$ftp_conn = ftp_connect($ftp_server) or die("Could not connect to $ftp_server");
$login = ftp_login($ftp_conn, "name",
从远程服务器获取ftp文件列表的最佳实践是什么?
1)使用ftp_connect()函数
<?php
// set up connection
$conn = ftp_connect($ftp_server);
// login with username and password
$login = ftp_login($conn, $ftp_user_name, $ftp_user_pass);
// get contents of the current directory
$content = ftp_nlist($conn, ".");
// output