CodeIgniter Forums
Best option to read files - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Best Practices (https://forum.codeigniter.com/forumdisplay.php?fid=12)
+--- Thread: Best option to read files (/showthread.php?tid=72514)



Best option to read files - Camp1 - 01-01-2019

What is the best option to read images?

Im not sure about, file helper: get_filenames($path)  or maybe directory_map($path).

Using filename I can get the url of the image but it also returns the names of the subdirectories and I do not want this. Using directory_map I can use directory depth.

I dont know what is the best option, I need the most optimal solution. Thanks! Big Grin


RE: Best option to read files - Pertti - 01-02-2019

Depends, what exactly are you trying to do?

If you are using CI4, in documentation it says you can tell it to leave out the path, setting second attribute to false (which should be false by default?)
https://codeigniter4.github.io/CodeIgniter4/helpers/filesystem_helper.html?highlight=get_filenames#get_filenames


RE: Best option to read files - Camp1 - 01-02-2019

Thanks for answering. I'm using CI3, and I want to show galleries of images, each gallery has a subdirectory, in this there is another subdirectory with thumbnails.


RE: Best option to read files - Pertti - 01-03-2019

Cool. I usually use scandir for all my file-list operations - http://php.net/manual/en/function.scandir.php