自定义下载名称<a href=""> tag

时间:2019-01-08 10:27:41

标签: javascript html5

I want to change the File name so i am trying to make use of Download Attribute. Here is the Code.

<a href="http://upload.wikimedia.org/1200.png" download = "MyName">
  Click Me
</a>

The file name doesn't get change. It remains 1200.png. I have noticed that when i use some local folder like '~/Images/file1.png' then it changes the name.

How to resolve this?

1 个答案:

答案 0 :(得分:4)

download attribute“仅适用于同源URL”。

您已经观察到,从相同来源(“某些本地文件夹”)提供文件是可行的,这是解决文件的唯一方法。