note 54307 added to function.ftp-nlist
| From: | dreamsavior at gmail dot com | Date: | Thu, 30 Jun 2005 04:19:21 +0000 |
| Subject: | note 54307 added to function.ftp-nlist | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-91173@lists.php.net to get a copy of this message | ||
Here is the function that would checking whether the given path is directory or not, using
ftp_nlist;
<?php
function is_ftp_dir($itempath, $ftp_server, $ftp_user_name='anonymous',
$ftp_user_pass='') {
if (empty($ftp_user_name)) {
$ftp_user_name = "anonymous";
}
if ($itempath[0]!=="/") {
$itempath = "/".$itempath;
}
$conn_id = ftp_connect($ftp_server);
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
$contents = ftp_nlist($conn_id, "$itempath");
if (!empty($contents[0])) {
$check = str_replace($itempath, "", $contents[0]);
if (!empty($check)) {
return true;
}
}
ftp_close($conn_id);
}
// example :
if (is_ftp_dir("/pub/ftp/unknownitem", "ftp.nowhere", 'username',
'verysecret'')) {
// do something related to directory handling action
} else {
// The target item is a file ...
}
?>
----
Manual Page -- http://www.php.net/manual/en/function.ftp-nlist.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+54307
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+54307&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+54307&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+54307&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+54307&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+54307&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+54307&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+54307&report=yes
Search -- http://master.php.net/manage/user-notes.php