note 31668 added to function.ftp-nlist
| From: | louis at ewens dot com | Date: | Tue, 29 Apr 2003 21:03:45 +0000 |
| Subject: | note 31668 added to function.ftp-nlist | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-47258@lists.php.net to get a copy of this message | ||
If you do a wildcard or other search for a particular file and the file doesn't exist, Solaris
FTP servers send back "search*.xml: No such file or directory" as a single element in the
response array. This makes it hard to check for the presence of a file.
One possible work-around is to parse your own raw directory listing. Or you could check for the
error verbatim. But different servers could return different values. A simpler way to compensate is
to use the ftp_size command to validate the returned file:
if ( ($filelist = ftp_nlist( $this->conn_id, $filesearch )) === FALSE )
{
Error( "Could not get file list" );
return FALSE;
}
// File actually exists? Catches invalid FTP server list responses
if ( !count($filelist) || ftp_size( $this->conn_id, $filelist[0] ) == -1 )
{
Error( "No valid files" );
return FALSE;
}
// File is really there, fetch it or whatever else you want to do
--
http://www.php.net/manual/en/function.ftp-nlist.php
http://master.php.net/manage/user-notes.php?action=edit+31668
http://master.php.net/manage/user-notes.php?action=delete+31668
http://master.php.net/manage/user-notes.php?action=reject+31668