javascript - Can cross-domain download files with a tag be renamed?
过去多啦不再A梦
过去多啦不再A梦 2017-05-24 11:33:26
0
2
1738

Can cross-domain download files with a tag be automatically renamed when clicking download?
The file is not on my server
I don’t want to save this file on my server
Is there a way for users to automatically rename the file name when downloading by clicking the a tag?

过去多啦不再A梦
过去多啦不再A梦

reply all(2)
仅有的幸福

You can use the HTML5中的download attribute, refer to w3school:

<a href="https://www.baidu.com/img/bd_logo1.png" download="baidu">

Attached is a cross-domain solution

Nginx (Same as Apache):

location /imgProxy {
    resolver 10.0.0.1;
    proxy_pass $arg_url;
}

<a href="/imgProxy?url=https://static.segmentfault.com/v-5922866b/global/img/logo-b.svg" download="logo">segmentfault</a> 
PHPzhong

Currently only Chrome supports this feature:

<a href="..." download="file.mp4">Download</a>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template