View Images in a Directory - Php Script

Discussion in 'PHP' started by sosmuthu, Sep 10, 2008.

  1. #1
    Im looking for a PHP script which automatically displays all the images inside a particular directory

    There were a lot of scripts when i searched,but i couldnt make them work(or may be i dnt know how to make it work!!)

    So could you share some links of scripts.Im looking for Free Scripts only

    The main work it has to do is * Just display all the images inside a directory
    I have a seperate directory for Thumbnails & Original Images
     
    sosmuthu, Sep 10, 2008 IP
  2. zerxer

    zerxer Peon

    Messages:
    368
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    0
    #2
    $imgs = glob("LOCATION/TO/IMAGES/FOLDER/*.{png,PNG,jpg,JPG,jpeg,JPEG,gif,GIF,bmp,BMP}", GLOB_BRACE);
    
    foreach($imgs as $img) {
      ?><img src="http://yoursite.com/<?=$img?>" /><?
    }
    PHP:
    Something like that should work. Sorry if you wanted an actual pre-made script; not sure if you know PHP yourself. Note that if for the location to images folder you use "/home/you/public_html/images/", the array it returns will contain paths like "/home/you/public_html/images/image1.jpg" and such which means the for loop won't print out proper image tags. You'll have to make it clean up the $img variable before actually putting it to use in the for loop.
     
    zerxer, Sep 10, 2008 IP
  3. sosmuthu

    sosmuthu Peon

    Messages:
    287
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I appreciate your Help,but im very weak in PHP..I could just mend some corrections but cant start from scratch

    I also heard that there are FREE php scripts to display the images in a directory..Also they are just a single file

    Im requiring this script to clean up the images in the directory,so i can just view the images and delete only those which are not good!
     
    sosmuthu, Sep 10, 2008 IP