I want to count files from a directory which is stored in a remote server .
I used the following code . But obtained warning

$dir = opendir($url);

//List files in images directory
while (($file = readdir($dir)) !== false)

  echo "filename: " . $file . "<br />";

Warning: opendir( [function.opendir]: failed to open dir: not implemented in C:\xampp\htdocs\divya\remote_files\remote.php on line 3

Warning: readdir() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\divya\remote_files\remote.php on line 6

Recommended Answers

All 2 Replies

From the manual:

"If path is not a valid directory or the directory can not be opened due to permission restrictions or filesystem errors, opendir() returns FALSE and generates a PHP error of level E_WARNING. You can suppress the error output of opendir() by prepending '@' to the front of the function name."

So, because your $url is missing file:// or ftp:// you get the error. Either that, or a permissions issue. As stated in your previous post on glob, you will need to find another way to do this.

`//For Local Server

function countFolder($dir)
    return (count(scandir($dir)) - 2);
} $dir is path of your director on local server

//For Web Server

$ftp = ftp_connect("your host");// yourhost.com
ftp_login($ftp, "username", "password");// 
echo count(ftp_nlist($ftp,$destpath));
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.