Get response file use ExtJS

后端 未结 2 517
情书的邮戳
情书的邮戳 2021-01-19 00:57

I use ExtJS to build the client-side for my program. There\'s a situation that I want to send an Ajax request to server, and get the response file (binary file, not plain te

相关标签:
2条回答
  • 2021-01-19 01:20

    You can save your file to server's file-system and send window.open('http://your.domain/your/file') to client side... where http://your.domain/your/file -link to file

    0 讨论(0)
  • 2021-01-19 01:23

    If you need the user to be prompted with the typical browser provided open/save dialog box, you don't need to make this call AJAX.

    Just linking to myController/exportFile from your page should be enough.
    e.g. <a href="myController/exportFile">my file</a>

    For this approach to work, HTTP response from myController/exportFile must include the appropriate headers (namely, Content-type and Content-disposition) that tell the browser "this is file. show open/save dialog" and based on your snippet, I see that you already have this taken care of.

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