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.


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.


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

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

使用JavaScript遍历本地文件夹的文件相关推荐

  1. [C#(WebForm)] - 利用递归遍历文件夹和文件存入TreeView

    主要函数:(具体实例在下面) //必须先引用命名空间:System.IO //使用relateTreeView函数时 path 路径使用本地路径,或经过Server.MapPath("服务器 ...

  2. 利用递归遍历文件夹和文件存入TreeView

    主要函数:(具体实例在下面) //必须先引用命名空间:System.IO //使用relateTreeView函数时 path 路径使用本地路径,或经过Server.MapPath("服务器 ...

  3. python 遍历文件夹和文件

    文件结构如下图 path = r"文件夹1" 遍历1层下的所有文件名和文件夹名 import os fileList = os.listdir(path) # 遍历1层 print ...

  4. java读取hdfs文件夹_HDFS 读取、写入、遍历文件夹获取文件全路径、append

    1.从HDFS中读取数据 Configuration conf = getConf(); Path path = new Path(pathstr); FileSystem fs = FileSyst ...

  5. QListWidget读取本地文件夹中文件并显示名字,双击读取xml数据

    文章目录 前言 一.读取本地文件并显示 二.双击读取数据 前言 本文主要是为了解决QListWidget读取本地文件夹中文件,并且显示的问题.然后双击读取其中xml数据 一.读取本地文件并显示 如下的 ...

  6. VBA遍历文件夹下文件文件实用源码

    '批量遍历文件夹下某类文件,并统计编号 Sub OpenAndClose()Dim MyFile As StringDim s As StringDim count As IntegerMyFile ...

  7. python修改文件后缀_python实现遍历文件夹修改文件后缀

    本文实例为大家分享了python实现遍历文件夹修改文件后缀的具体代码,供大家参考,具体内容如下 用法 python Modifer.py ./ -fp java xml # coding:utf-8 ...

  8. php文件遍历类,PHP 遍历文件夹及文件类及处理类

    FindFile.class.php 用于遍历目录文件 /** 遍历文件夹及文件类 * Date: 2013-03-21 * Author: fdipzone * Ver: 1.0 */ class ...

  9. php遍历文件夹下文件内容_php实现的遍历文件夹下所有文件,编辑删除

    遍历文件夹; 功能:(a)可删除文件 (b)可编辑文本,网页文件 (c)可删除文件夹,前提是该文件夹为空 (d)可建立文件,文件夹,修改文件夹名称 /* 遍历文件夹; 功能:(a)可删除文件 (b)可 ...

  10. HDFS 读取、写入、遍历文件夹获取文件全路径、append

    版权声明:本文为博主原创文章,未经博主同意不得转载.安金龙 的博客. https://blog.csdn.net/smile0198/article/details/37573081 1.从HDFS中 ...

最新文章

  1. neo4j中文社区 php,neo4j 社区版搭建教程
  2. 嵌入式 Jlink中flash.csv和*.jflash文件分析
  3. python词云有什么用_如何用Python实现词云效果
  4. python树莓派串口通信实例_Python实现树莓派USB串口通讯及云端对接
  5. 【SPOJ 694】Distinct Substrings (更直接的求法)
  6. 第3章 Python 数字图像处理(DIP) - 灰度变换与空间滤波2 - 图像反转、对数变换
  7. Uboot初次编译、烧写、启动(启动界面log简析)
  8. 《程序设计与数据结构》第3周学习总结
  9. mysql 命令行批量sql_命令行中执行批量SQL的方法
  10. C# CollectionBase,ICloneeable
  11. PHP多进程网络爬虫
  12. 欧姆龙多PLC串行链接模式的应用
  13. 《IBM SPSS Modeler数据与文本挖掘实战》之社交网络分析
  14. Acer宏碁笔记本触摸板失效解决方法
  15. 80多款装机必备软件,一次搞定
  16. Chalcolithic 铜石并用时代
  17. 手机上最好用的五笔输入法_什么手机输入法最实用?目前最受欢迎的3款盘点,你正在用哪款呢...
  18. Icebound and Sequence(等比数列公式的递归处理)
  19. 沉痛悼念互联网[云原生领域]技术大牛----左耳朵耗子(陈皓老师)
  20. 天猫精灵智能设备对接(2)

热门文章

  1. Linux下的字符处理命令之tr命令详解
  2. Android--生命周期【转】
  3. 开学前要多为孩子健康做准备
  4. Jython 安装使用
  5. Centos下的apache2练习
  6. 基于vue 2.X和高德地图的vue-amap组件获取经纬度
  7. web容器(03):Nginx配置负载均衡
  8. qt5.3.2移植到arm上出undefined reference to '__sync_sub_and_fetch_4的错
  9. 简单介绍VS2015自动测试工具
  10. VS2015中的项目类图