Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Problem with folder!

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, biapar, Willr, Ingo, simon_w

Page: 1
Go to End
Author Topic: 1003 Views
  • juandavidgc
    Avatar
    Community Member
    36 Posts

    Problem with folder! Link to this post

    Hi!!

    I have a problem. I need to read the files that are allocated into a folder in assets/Uploads/Event/.

    Well, i dont know how i get the list of files that are in this folder, and i need the list of files that are in the sub-folders.

    Thanks for your help!

  • juandavidgc
    Avatar
    Community Member
    36 Posts

    Re: Problem with folder! Link to this post

    Hi

    Problem solved...

    I made this

    if (is_dir($dir))
          {
             if ($dh = @opendir($dir))
             {
                while (($file = @readdir($dh)) !== false)
                {
                   $lista.="Archivo: $file : Extensión: " . filetype($dir . $file) . "<br>";
                }
             }
          }
    @closedir($dh);

    but the dir must be start with /var/www/mysite/assets/Uploads/folder/

  • Fuzz10
    Avatar
    Community Member
    787 Posts

    Re: Problem with folder! Link to this post

    You can use internal SS DataObject functions for this as well... ...

    That would look something like this :

          $left_dir = DataObject::get_one("Folder", "Name = \"directoryname\"");

          $all_files = DataObject::get("File","ParentID = $left_dir->ID");

    1003 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.