遍历文件夹_使用JavaScript遍历本地文件夹的文件

1265fe8f551b78399285c75e1d96a393.png

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.

512d8f2514abb96846fd6eb768d7ff08.png

67af8df42879a7c0b1200cbff5c3ac92.png

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.

bde118a28ba67774378734a583abc385.png

d2015facca4e5d3d9e1416e2db03446c.png

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

688cffb84459e68577396679e3542995.png

要获取更多Jerry的原创文章,请关注公众号"汪子熙":

a94ea35f08a1a7512a2211ea91480026.png
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值