Javascript rename file on download

前端 未结 6 2018
粉色の甜心
粉色の甜心 2021-01-11 11:08

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

Ex: File: http:////test.txt

6条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-11 11:31

    You can't do that in Javascript. The "Save to"-dialog is openend by the browser and you can't access that through JS, it's a standard-dialog from the OS.

    Your server must provide the file with the desired name before the user clicks on the download-link.

    What's the reason that you want to rename the downloaded file anyway?

提交回复
热议问题