开发者

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!!


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.


If the server containing the images is in your control, you can have a PHP script list out all the image names by using readdir() function. Then you call this script from the other server and read/parse all the files names.

If you dont control the server hosting the files then this is not really possible unless they have directory listing enabled on that images directory.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜