DEV Community

Cover image for Image gallery without database

Image gallery without database

marvinoliveiras profile image Marcos Silva Updated on ・1 min read

This image gallery was developed using only PHP in the beckend, it is not necessary to use a database. As for the frontend, it was developed using only HTML, CSS and JavaScript.

how is it possible not to use DB?

This is possible thanks to the FilesystemIterator class, this class is native to PHP and it returns a list of files and folders that are inside the directory informed in its constructor. Note: this instance of FilesystemIterator, as its name suggests, is iterable as an array, that is, it can be used directly in a repetition structure such as for (), foreach () and etc.. See the example:

$files = new FilesystemIterator(
foreach($files as $file){
    echo $file
Enter fullscreen mode Exit fullscreen mode

The above code will print:

Enter fullscreen mode Exit fullscreen mode

If interested, please leave your review.
This is my repository with the complete gallery, including the secure upload of images, let your star like the idea
Image Gallery Without database
By my code do you imagine that I can be the junior developer?

Sorry my English, blame Google Translate. :tw-1f605:

Discussion (0)

Forem Open with the Forem app