简体   繁体   中英

Local network php gallery - need to grab images off drive?

Ok, I'm building a simple php gallery that'll act as a photo browser for several pcs and tablets across the house. I have a NAS which has a single drive containing all our photos and I'd like my php app to randomly select 50 every day and display them as a slideshow.

Can anyone tell me if this is possible with php or whether I'll need to have a separate application grabbing the random selection each day and creating some sort of feed for it to access?

Any thoughts much appreciated!

Certainly doable, but since it's just once a day, have some OTHER script find/generate the images-to-display list and run it via a daily cron job. Better than having your "show the list" script having to check everytime it runs whether it should generate list.

That other script can still be written in PHP, just keep it separate from the display logic.

If the machine running PHP has access to the NAS via a shared folder or mapped drive, you can access the files on the NAS using the Filesystem Functions and Directory Functions .

See opendir() and readdir() specifically.

Rather than continually fetch the images from the NAS, you could download them to a local temp directory using something like file_get_contents() .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM