Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Archive /

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

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

Problem with folder!


Go to End


3 Posts   1300 Views

Avatar
juandavidgc

Community Member, 36 Posts

13 September 2008 at 12:12am

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!

Avatar
juandavidgc

Community Member, 36 Posts

13 September 2008 at 1:59am

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/

Avatar
Fuzz10

Community Member, 791 Posts

13 September 2008 at 2:05am

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");