List Info

Thread: note 78447 added to function.ftp-nlist




note 78447 added to function.ftp-nlist
user name
2007-10-12 08:28:18
In order to make file/folder separation work on remote
servers that do not support ftp_size() it's better to use
the function ftp_is_dir() mentioned below:

<?php

//identify directories

function ftp_is_dir($dir) {
  global $ftp_connect;
  if (ftp_chdir($ftp_connect, $dir)) {
    ftp_chdir($ftp_connect, '..');
    return true;
  } else {
    return false;
  }
}
$ftp_nlist = ftp_nlist($ftp_connect, ".");

//alphabetical sorting

sort($ftp_nlist);
foreach ($ftp_nlist as $v) {

//1. ftp_is_dir() is true => directory
  if (ftp_is_dir($v)) {

//output as [ directory ]
      echo "[ " . $v . " ]<br
/>n";
  }
}
foreach ($ftp_nlist as $v) {

//2. ftp_is_dir() is false => file
  if (!ftp_is_dir($v)) {

//output as file
      echo "" . $v . "<br />n";
  }
}
?>
----
Server IP: 217.13.201.10
Probable Submitter: 134.245.122.86 (proxied: 134.245.191.7)
----
Manual Page -- h
ttp://www.php.net/manual/en/function.ftp-nlist.php
Edit        -- https://master
.php.net/note/edit/78447
Del: integrated  -- h
ttps://master.php.net/note/delete/78447/integrated
Del: useless     -- http
s://master.php.net/note/delete/78447/useless
Del: bad code    -- htt
ps://master.php.net/note/delete/78447/bad+code
Del: spam        -- https:/
/master.php.net/note/delete/78447/spam
Del: non-english -- 
https://master.php.net/note/delete/78447/non-english
Del: in docs     -- http
s://master.php.net/note/delete/78447/in+docs
Del: other reasons-- https://mast
er.php.net/note/delete/78447
Reject      -- https://mast
er.php.net/note/reject/78447
Search      -- https://
master.php.net/manage/user-notes.php

-- 
PHP Notes Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub
.php


[1]

about | contact  Other archives ( Real Estate discussion Medical topics )