Javascript重命名下载文件 [英] Javascript rename file on download

查看:28
本文介绍了Javascript重命名下载文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够下载网络文件,但是当下载对话框打开时,文件名被重命名.

I want to be able to download a web file, but when the download dialog open, the filename is renamed.

例如:文件:http:////test.txt

当我点击下载文件时,下载对话框打开,文件名:test001.txt.

and when I click to download the file, download dialog open with the file name: test001.txt.

我怎样才能做到这一点?

How can I achive that?

推荐答案

正如 InviS 所建议的,现在链接上有一个 download 属性.

As InviS suggests, now there's a download attribute on links.

示例:

<a href="http://server/site/test.txt" download="test001.txt">Download Your File</a>

  • 规范
  • 文章
  • 浏览器支持(当时 Chrome、FF、Opera、Android 浏览器 >= 4.4.4写作)
    • spec
    • article
    • browser support (Chrome, FF, Opera, Android Browser >= 4.4.4 at the time of writing)
    • 这篇关于Javascript重命名下载文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆