js遍历服务器文件夹,使用JavaScript遍历本地文件夹的文件

This blog is written based on Chrome 45.0.2454.85 m.

In HTML5 there is one additional attribute available for tag a, the “download”. By clicking on the “a” tag with “download” attribute, you can directly get download operation performed. See the simple example below:

Click Save hyperlink, the download is executed immediately and I have a downloaded file with correct name and content specified in the example.

199517643_1_20200817104541161.png

199517643_2_20200817104541208_wm.jpg

This useful attribute could help us to finish some task without intensive programming. For example, I need to get the file list of a given folder in my laptop via JavaScript. Here below is how to achieve it:

(1) Create a simple html page with source code below and open it via Chrome. (2) Open Chrome development tool, type the command like below. There is a notification poped up by Chrome, asking you if you allow the file download. Click ok. Then a html file is automatically downloaded by Chrome.

199517643_3_20200817104541255_wm.jpg

199517643_4_20200817104541333_wm.jpg

Open the html source code and compare its content with the actual files in your local folder. They are exactly matched.

199517643_5_20200817104541396_wm.jpg

  • 3
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值