ftp_nlist problem.
| From: | Martin Nilsson | Date: | Wed, 07 Jun 2000 09:34:56 +0000 |
| Subject: | ftp_nlist problem. | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-1193@lists.php.net to get a copy of this message | ||
Hello!
I'm programming a ftp-client which should be managed via a webbrowser. If I connect to a ftpserver which is running Linux Redhat 6.0 or Windows 2000 it works as desired. Both files and directories are showed. Both if I connect to a ftpserver which is running Linux Mandrake o Sun Solaris it doesn't work. In Mandrake _only_ files are showed and in Solaris _only_ directories are showed. Of course there is both files and directories in the listed directory.
Anyone who have had this error to?
Regards Martin
Server Configuration:
Linux Mandrake 7.0
Apache 1.3.12 (apache-1.3.12-10mdk.i586.rpm)
PHP3 (mod_php3-3.0.16-2mdk.i586.rpm)
Snipp from my FTP class:
// List a remote directory. Returns the filenames as an array, false if the operation fails.
function listDir($directory)
{
if(!$this->ftpLink)
{
$this->connect($this->ftpUser, $this->ftpPassword, $this->ftpServer);
if($this->errNr)
{
return;
}
}
$originalDir = $this->pwd();
if(!$this->errNr)
{
$this->cd($directory);
if(!$this->errNr)
{
$list = ftp_nlist($this->ftpLink, ".");
if($list)
{
sort($list);
$count = sizeof($list);
$countFiles = 0;
for($i = 0; $i < $count; $i++)
{
$fileSize = $this->fileSize($list[$i]);
if($this->errNr == 110) // If this is true then it's a directory.
{
$fileList[$countFiles] = $list[$i]; // Copy the filename to a filelist. We skip all the directories.
$countFiles++;
}
}
$this->cd($originalDir);
if(!$this->errNr)
{
unset($this->err);
$this->errNr = 0;
return $fileList; // Operation successfully!
}
else
{
return; // cd above failed. What should we do here?
}
}
else
{
$fileList = false; // OBS !!!!!!! No directories in directory OR ftp_nlist failed.
return $fileList;
//$this->cd($originalDir);
//$this->err = "Couldn't get filelist. Operation ftp_nlist failed.";
//$this->errNr = 109;
//return;
}
}
else
{
return;
}
}
else
{
return;
}
}
End snipp.
listFiles lookes similar but returns the files in the directory.
_____________________________________
Martin Nilsson
Student at University of Karlskrona/Ronneby
di97mni@student.hk-r.se
rufus@web.com
_____________________________________