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

后端 未结 6 1185
心在旅途
心在旅途 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:38

    You can't do this with client-side JavaScript, you need to set the response header...

    .NET

    Response.AddHeader("Content-Disposition", "inline;filename=myname.txt")
    

    Or PHP

    header('Content-Disposition: inline;filename=myname.txt')
    

    Also available in other server-side languages of your choice.

提交回复
热议问题