如何使用HTML-Javascript-CSS从文件夹中顺序显示图像?

时间:2021-11-26 06:07:14
  • There are few images stored in a folder with random names.
  • 存储在具有随机名称的文件夹中的图像很少。

  • The contents of the folder will constantly be changing but they will have only images and no other kind of documents.
  • 文件夹的内容将不断变化,但它们只有图像而没有其他类型的文档。

  • Therefore i cannot predefine the image names in src.
  • 因此我无法在src中预定义图像名称。

  • I want to display the images sequentially (one after another with specific time interval) using HTML-Javascript-CSS codes.
  • 我想使用HTML-Javascript-CSS代码按顺序显示图像(一个接一个地显示特定的时间间隔)。

  • The folder is on the client side only.
  • 该文件夹仅在客户端。

  • Or atleast i should be able to read the filenames in the folder.

    或者至少我应该能够读取文件夹中的文件名。

    I cannot use PHP. How do i do this?

    我不能使用PHP。我该怎么做呢?

Thank you in advance!

先感谢您!

1 个解决方案

#1


1  

I think this is not trivially possible for security reasons. No webpage (even locally) is allowed to simply read your folder content. There have been some workarounds for some browsers, but I don't think there is a true Cross-Browser solution.

我认为出于安全原因,这并非易事。不允许任何网页(甚至本地)只读取您的文件夹内容。某些浏览器有一些变通方法,但我认为没有真正的跨浏览器解决方案。

That said, there is the HTML5 file API that allows the user to select the images or drag and drop them to a local website.

也就是说,HTML5文件API允许用户选择图像或将其拖放到本地网站。

Another option would be to have a small executable file that creates for instance a json List of your files and have the website read the filenames from there.

另一种选择是拥有一个小的可执行文件,例如创建一个文件的json列表,让网站从那里读取文件名。

After you have the filenames, use any HTML/JS/CSS gallery.

获得文件名后,请使用任何HTML / JS / CSS库。

#1


1  

I think this is not trivially possible for security reasons. No webpage (even locally) is allowed to simply read your folder content. There have been some workarounds for some browsers, but I don't think there is a true Cross-Browser solution.

我认为出于安全原因,这并非易事。不允许任何网页(甚至本地)只读取您的文件夹内容。某些浏览器有一些变通方法,但我认为没有真正的跨浏览器解决方案。

That said, there is the HTML5 file API that allows the user to select the images or drag and drop them to a local website.

也就是说,HTML5文件API允许用户选择图像或将其拖放到本地网站。

Another option would be to have a small executable file that creates for instance a json List of your files and have the website read the filenames from there.

另一种选择是拥有一个小的可执行文件,例如创建一个文件的json列表,让网站从那里读取文件名。

After you have the filenames, use any HTML/JS/CSS gallery.

获得文件名后,请使用任何HTML / JS / CSS库。