CodeIgniter Forums
Read a directory - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Read a directory (/showthread.php?tid=21275)



Read a directory - El Forum - 08-05-2009

[eluser]R. Oerlemans[/eluser]
Hi There,

For a new project I need a script what can read directories. I've a sctructure like:
Quote:- Images
- Avatars
- username.jpg
- username2.jpg
- Uploads
- username
- upload1.jpg
- upload2.jpg
- username 2
- Empty

Now I would put the records in a mySQL database like:

=== Uploads ===
i_id
u_id (user id)
url

Coud anyone help me with a script what read the directory out.

Thank you very much for reading and maybe helping.


Read a directory - El Forum - 08-05-2009

[eluser]rdjs[/eluser]
There is a function in the CodeIgniter directories helper which:

"reads the directory path specified in the first parameter and builds an array representation of it and all its contained files"

Code:
directory_map('source directory')

See the Directories Helper in the CodeIgniter User Guide for more info.