You can do a request using jQuery (like ajax()
or post()
methods) and get a HttpResponse
with the file content and the desired headers. Obviously you'll need a server-side technology (ASP.NET, Java, PHP etc.) to receive the HttpRequest
and return the HttpResponse
.
Then, your browser will intercept this response as a download.
Also, you can simple redirect the URL to the file, whithout manual post, like pointed on this thred: Download File Using jQuery. In this case, the browser will do the request for you, read the response and interpret as a download.
But you cannot specifies where the user will choose to save the file (nor the name). Also, the user always can cancel any download. And finally, the browser's security can be configurated to deny downloads.
Finally is important to remeber that the browser will show a download window per time. Then, you cannot start 10 downloads at the same time. Do you use Gmail? As you can see there, when a user wants to download all attachments at the same time, Gmail creates a ZIP with all files inside and sends the download of that ZIP. This is the better automatized way to do it, but also don't is what you desire.