Search code examples
phpfilelocalhostglob

How to count number of files in a folder in a remote host with a php file in localhost?


I want to count number of files in a folder in a remote host. The path is traversable. The file which I want to check with is in localhost?
How to do that?
I couldn't find an example that uses glob function to get files in a remote host. Is it possible?


Solution

  • You cannot execute code at a remote host. A better solution would be to place a script that counts the files and echos the number at the remote host, then do:

    $num_files = file_get_contents('http://remoteaddr/count_files.php');