I used the code given below to take the count of files in a folder which is in another machine. On my localhost the glob() is working fine, BUT on the server it displays the array size as 0.

$dir_path ="$sub_code/$sub_code".N."$churunano/*.jpg*";
$count = count(glob($dir_path));

How to find the count of the files?

Note: This function will not work on remote files as the file to be examined must be accessible via the server's filesystem.

Taken from: http://php.net/glob

What you could do is put a script with glob on that server, and retrieve the result using cUrl.