Gallery loads images from folder | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Gallery loads images from folder

Hey guys, does anyone know, how to program a gallery which adds uploaded images? I already have a website, where you can upload images which than will be saved in a folder of the server. Now my question. How can I make a gallery which dynamicly adds new uploaded images? Sorry, if this question was stupid, I'm very new to this topic... Thanks for answers

13th Apr 2021, 8:07 AM
LeChuck_42
LeChuck_42 - avatar
3 Answers
+ 2
Do you have a gallery on your website already with some images showing? If you do, the change could be as simple as replacing your hardcoded list of image URL's with code that lists all files in your upload directory and filters to images that you want. Unless nothing but images are there, you may want to filter to files ending with .jpg, .jpeg, .png, or .gif. What programming language are you using in the web server? Can you share a link to your website?
13th Apr 2021, 12:28 PM
Josh Greig
Josh Greig - avatar
0
Hey, thanks for the answer and no, I'm not already having a gallery on my website and my website isn't online... For backend I'm using PHP.
15th Apr 2021, 8:29 AM
LeChuck_42
LeChuck_42 - avatar
0
LeChuck_42 wrote, "Hey, thanks for the answer and no, I'm not already having a gallery on my website and my website isn't online... For backend I'm using PHP." Response: There are many JavaScript libraries to help with your gallery. Here are some jquery plugins for photo galleries: https://www.jqueryscript.net/gallery/ Pick whichever looks best on your site. One way to get all your images into the gallery would be to have all image URL's come with the HTML of your gallery page. That'll work. Another way that will work is to make an API in PHP and let JavaScript relay the response from that API into your gallery plugin. You could adapt this answer below to list only .png, .jpg, .jpeg from your upload directory: https://stackoverflow.com/questions/15870159/list-files-on-directory-and-print-result-as-json I would have replied days ago but the post of answers from the sololearn website kept breaking on me.
17th Apr 2021, 3:08 AM
Josh Greig
Josh Greig - avatar