[removed] how to load all images in a folder?

前端 未结 4 1233
你的背包
你的背包 2020-12-06 18:18
var img = new Image();
img.src = \"images/myFolder/myImage.png\";

The above will only load myImage.png. How to load all images of myFolder?

4条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-06 19:08

    JavaScript can't directly access the contents of a file system. You'll have to pass the contents using a server-side script (written in PHP, etc) first.

    Then once you have that, you can use a loop in your JavaScript to load them individually.

提交回复
热议问题