Answer the question
In order to leave comments, you need to log in
How to send a file for download in a browser?
I have a web application, Spring, on the html front with thymeleaf, js in some places.
There is a scenario in which the user enters data into the form, I need to generate a file from them and issue it to the user. I'm generating the file, but I can't figure out how to give it away.
There was an idea to put it on the server and make a download link, but the fact that the browser forbids links with "file:" interferes.
How else to push my file into the browser?
Answer the question
In order to leave comments, you need to log in
Here are examples of the implementation of download files
https://www.javainuse.com/spring/boot-file-download
https://o7planning.org/ru/11765/spring-boot-file-d...
https:// stackoverflow.com/questions/29816121/creat...
Why do you need links file:
, junkie? 0_o
file:
this is for links to local files on the user's computer, not abstract "files" on the server.
Files from the server fly on the same http:
/ https:
as everything else.
When processing the form, you return a normal http response. Here in this answer you put the title
Content-Disposition
and spit the contents of the file in its purest form.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question