1,105,254 Community Members

counting number of files from a remote server

Member Avatar
divyakrishnan
Posting Whiz in Training
243 posts since May 2010
Reputation Points: 20 [?]
Q&As Helped to Solve: 24 [?]
Skill Endorsements: 4 [?]
 
0
 

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

<?php
$url='192.168.0.138/img/12/12N69/';
$dir = opendir($url);

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

  echo "filename: " . $file . "<br />";
  }
closedir($dir); 
?>

Warning:
Warning: opendir(http://192.168.0.138/img/12/12N69/) [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
filename:

Member Avatar
pritaeas
mod_pritaeas
11,295 posts since Jul 2006
Reputation Points: 1,420 [?]
Q&As Helped to Solve: 1,832 [?]
Skill Endorsements: 155 [?]
Moderator
Featured
Sponsor
 
0
 

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.

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article