note 73401 added to function.ftp-nlist
| From: | josh at servebyte dot com | Date: | Wed, 21 Feb 2007 18:40:26 +0000 |
| Subject: | note 73401 added to function.ftp-nlist | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-123675@lists.php.net to get a copy of this message | ||
Function Keywords: is_file is_dir
<?php
$ftp_server = 'IP OR HOSTNAME HERE';
$ftp_user_name = 'USERNAME';
$ftp_user_pass = 'PASSWORD';
// set up basic connection
$conn_id = ftp_connect($ftp_server);
// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
function ftp_is_dir($folder) {
global $conn_id;
if (ftp_chdir($conn_id, $folder)) {
ftp_chdir($conn_id, '..');
return true;
} else {
return false;
}
}
function xdir($path) {
global $conn_id;
$contents = ftp_nlist($conn_id, $path);
foreach($contents as $file) {
if ($file!='.'&&$file!='..') {
if (ftp_is_dir($file)) {
echo $file . ' is a folder<br>';
} else {
echo $file . ' is a file<br>';
}
}
}
}
xdir('.');
?>
can be looped through... using the function xdir if the file is a folder ;)
Returns a warning upon not being a folder... use error_reporting(0); to resolve this issue.
----
Server IP: 212.108.64.74
Probable Submitter: 159.134.221.211
----
Manual Page -- http://www.php.net/manual/en/function.ftp-nlist.php
Edit -- https://master.php.net/note/edit/73401
Del: integrated -- https://master.php.net/note/delete/73401/integrated
Del: useless -- https://master.php.net/note/delete/73401/useless
Del: bad code -- https://master.php.net/note/delete/73401/bad+code
Del: spam -- https://master.php.net/note/delete/73401/spam
Del: non-english -- https://master.php.net/note/delete/73401/non-english
Del: in docs -- https://master.php.net/note/delete/73401/in+docs
Del: other reasons-- https://master.php.net/note/delete/73401
Reject -- https://master.php.net/note/reject/73401
Search -- https://master.php.net/manage/user-notes.php