How do I change a filename on-download with javascript?

后端 未结 6 1183
心在旅途
心在旅途 2021-02-02 16:03

The script adds a download link for videos (on a specific site). How do I change the filename to something else while downloading?

Example URL:
\"http://websit         


        
6条回答
  •  有刺的猬
    2021-02-02 16:32

    The filename for downloading is set in the header (take a look at "Content-Disposition"), wich is created on server-side.

    There's no way you could change that with pure javascript on a file you're linking to unless you have access to the server-side (that way you could pass an additional parameter giving the filename and change the server-side behaviour to set the header to match that... but that would also be possible with pure html, no need for javascript). Conclusion: Javascript is absolute useless to achive what you want.

提交回复
热议问题