<img src="" width="300px" height="200px" alt="foto"> <img src="" width="300px" height="200px" alt="foto"> <img src="" width="300px" height="200px" alt="foto"> 

How to create an array with photo addresses and scroll through them in a loop and assign them img src

Closed due to the fact that the essence of the issue is not clear to the participants of Darth , aleksandr barakin , pavel , kizoso , MedvedevDev Oct 20 '17 at 17:12

Try to write more detailed questions. To get an answer, explain what exactly you see the problem, how to reproduce it, what you want to get as a result, etc. Give an example that clearly demonstrates the problem. If the question can be reformulated according to the rules set out in the certificate , edit it .

  • if browser javascript is meant, then nothing. he doesn't have access to the file system - Grundy
  • If nodejs is meant, then it is here - Darth
  • @Grundy what does nodejs have to do with it? why it is impossible to create such an array? var images = ['../../image/ foto-1.jpg', '../../image/ foto-2.jpg', '../../image/ foto-3.jpg ']; for example, we don’t know what is the structure of files on the server or I don’t understand something? - Air
  • Mihail Yanenko, write a detailed question? - Air
  • @Air, while the author does not want to simply create an array, he wants to create an array that contains the names of the images in a particular folder . Consequently, it was assumed that the javascript itself would be engaged in this, and not the programmer each time would manually fill in all the file names from the desired folder. Maybe I was mistaken in this assumption, but in any case, it is still unclear what exactly the author of the question wants to get. - Grundy

1 answer 1

Browser js does not have access to the file system for security reasons.

Node.js has an fs module for working with the file system. There are two methods that suit you: asynchronous readdir and normal readdirSync .