How to specify download location in Html using JavaScript

前端 未结 1 602
迷失自我
迷失自我 2020-12-03 23:48

is it possible to specify the download location for a file from a Html page using JavaScript?

the function I am currently using to down my file is provided below.

相关标签:
1条回答
  • 2020-12-04 00:01

    Whether the browser asks the user or not is down to the preferences in the browser.

    You can't bypass those preference, otherwise it would violate user's security.

    What you can do is make sure you're sending the browser as much information as possible to help it make for a good user experience. If you're not already doing so, be sure to include a Content-Disposition header in the response to the download request, including a filename field:

    Content-Disposition: attachment; filename=test.csv
    

    Also see these other stackoverflow questions:
      Specify default download folder - possibly with JavaScript?
      Set file download destination using ExtJs

    0 讨论(0)
提交回复
热议问题