Need som php help with picture and a directory

Discussion in 'PHP' started by micromark, Oct 17, 2007.

  1. #1
    Hi,

    I have a folder of images on my server and each day I want a new image to be picked and displayed from this folder.

    What would be the best way of doing this ?

    Thanks.
     
    micromark, Oct 17, 2007 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    Do you want a specific image related to the current day or a random image?
    How many images are in the folder?
    How often is this folder updated?
     
    nico_swd, Oct 17, 2007 IP
  3. micromark

    micromark Peon

    Messages:
    466
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #3
    hello,

    I want a random image, picked everyday.

    There will be many images in the folder and new ones being updated.

    I cant say when the folder is updated, sometimes twice a day sometimes once a month.
     
    micromark, Oct 17, 2007 IP
  4. jnestor

    jnestor Peon

    Messages:
    133
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I'd setup a cronjob to run once a day, pick a random image and soft link it to a fixed name.
     
    jnestor, Oct 17, 2007 IP
  5. ste.richards

    ste.richards Guest

    Messages:
    46
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Get the directory contents using opendir() and readdir() and store the filenames in an array. Then use the count() function to see how many are there and then the rand() function to pick a random one.

    Regards,
     
    ste.richards, Oct 17, 2007 IP
  6. micromark

    micromark Peon

    Messages:
    466
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Any1 got an example ?
     
    micromark, Oct 18, 2007 IP