Search code examples
phpapachecommand-lineosx-server

Get text data name list from folder on server


Not sure if this is possible or not?

I need contents of a file directory from another server in order to make a photogallery on another server.

Let's say I have a Folder on server1 named "folderName1" and the contents in the folder are images, like:

2005-14-05-this-that.jpg
2005-14-06-this-that.jpg
2005-14-07-this-that.jpg
2005-14-08-this-that.jpg
2005-14-09-this-that.jpg....

In order to make use this gallery script, I need to get a text file with this information on it.. Some folders I have 1000's of photos in them and it takes to long to write them all down..

Wondering if there is a shortcut to GET all contents from a folder and spit them out in a text file??

Thanks!!


Solution

  • http://php.net/manual/en/function.readdir.php

    place a script on server1 (perhaps in each directory that has photo's) called 'imagelist.php'. This script loops all files according to the function I placed above and echoes every image on it's own line.

    Then server2 could request this file using file_get_contents() and loop everyline and use the filenames to create a gallery.