Answer the question
In order to leave comments, you need to log in
How to get file from server in Angular?
Good day.
I am developing a web application using angular and php. The form has fields that are sent to the server and a Word file is generated, which then must be immediately downloaded to the user's computer. Data is sent from the client using angular, and php is running on the server. The question is this: how do I get php to send a file as a response, which would be immediately downloaded to the client?
Answer the question
In order to leave comments, you need to log in
In the response (php script) put a Content-Type header and choose a mime type for your file. Then, using the same php, feed the generated file into response. All. The browser will look at the content-type and prompt the user to save it.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question