How do I count files in a directory using jQuery?

前端 未结 4 1701
[愿得一人]
[愿得一人] 2020-12-06 16:06

I\'d like to count the number of files in a folder and return that number to set a variable in a .js file.

Essentially, I have X number of images in a folder. When t

4条回答
  •  感情败类
    2020-12-06 16:37

    If you must use client side and the files are numbered, preload the file and set the number when you get an error

    ...
    Img = new Image();
    Img.onerror=function() {
      maxImages=cnt-1;
    }
    Img.src = "image_"+cnt+".jpg";
    

提交回复
热议问题