searching files in a folder |
[eluser]A.M.F[/eluser]
how can i search for images inside a folder and count them? e.g i want to print all the images, in the folder FOLDER, that their name starts with an A thanks
[eluser]xwero[/eluser]
You can use get_filenames from the file helper to get the filenames from the folder and then you do a loop Code: function filter_directory($path,$regex) Code: $files = filter_directory('my/albums','/^a/i');
[eluser]A.M.F[/eluser]
that what i tried to do but i keep getting the same error: Quote:A PHP Error was encountered although the direcotry does exists and it is on my local server on my computer (i am using WAMP). when i am trying to go to directory through the browser i get a FROBIDDEN error. why?
[eluser]xwero[/eluser]
Change your apache settings to allow script access for that directory. I've modified the function: $path instead of 'path/to/directory'.
[eluser]A.M.F[/eluser]
[quote author="xwero" date="1203699831"]Change your apache settings to allow script access for that directory. [/quote] how can i do it? *this directory is inside my CI directory
[eluser]xwero[/eluser]
you have to change your httpd.conf or add a .htaccess file with following line in it Quote:Allow from allor Quote:Allow from 127.0.0.1
[eluser]m4rw3r[/eluser]
If you only want to filter with a prefix/suffix etc, you can use the glob() function: www.php.net/glob
[eluser]xwero[/eluser]
nice call m4rw3r Code: function filter_directory($pathregex,$nameregex) Code: $files = filter_directory(real_path('my/albums').'/*\.jpg|gif|png','/^a/i'); |
Welcome Guest, Not a member yet? Register Sign In |