www.webdeveloper.com
Results 1 to 2 of 2

Thread: [RESOLVED] Getting all images from one folder and subfolders

Hybrid View

  1. #1
    Join Date
    Jul 2012
    Posts
    12

    resolved [RESOLVED] Getting all images from one folder and subfolders

    Hi guys,
    I have a gallery where users can upload their images, and update or delete them.
    All users images are then displayed in a main gallery page.

    The way i did it was: create a condition that checks if a folder with the user name exists inside the gallery folder.
    If it doesn't it creates a new folder with the user name, and then moves the image being uploaded to the user folder.

    Now, each user has his own page named "my-images.php" where they can manage only their images. The source folder points only to his folder, so only their images are displayed.

    Everything works fine here. The problem is in the main gallery, because i have to source the image from all
    subdirectories inside the gallery directory.

    the original image output
    PHP Code:

    <a href="images/gallery/<?php echo($value['image']);?>" target="_blank">
                <img alt="" border="2px" width ="150px" height="113px" src="images/gallery/<?php echo($value['image']);?>">
    </a>
    I tried changing to
    HTML Code:
     src="images/gallery/*/
    didn't work.

    I read something online about the glob() function.
    But I'm not really sure how am I about to implement it in this particular case.


    Any help is welcome,
    Mike

  2. #2
    Join Date
    Jul 2012
    Posts
    12
    OK i found a way around.
    I'm adding the user name to database table where image name is kept,
    the extraction script I changed to:
    Code:
    <a href="images/gallery/<?php echo($value['image']);?>" target="_blank"> 
                <img alt="" border="2px" width ="150px" height="113px"
                   src="images/gallery/<?php echo($value['user']);?>/<?php echo($value['image']);?>"> 
    </a>
    very easy in my particular case, but if i was to do the same but in a situation where the folder names have nothing to do with the users... that'lb something else .

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles