E
E
EvgMul2019-01-20 20:15:47
Yii
EvgMul, 2019-01-20 20:15:47

How to give the user a file after submitting the form using ajax in Yii2?

Hello. There was such a problem, I can not figure out how to solve it.
Essence in the following: on the page there is a form for filling. It is required to make sure that after the form has been filled out and the submit button is pressed, the filled data is saved to the model, and the corresponding file is given to the user.
The difficulty is that the user must remain on this page and it is desirable not to reload it.
Those. the person opened the page, filled out the form, pressed the button, and a standard browser window appeared to download the file. He downloaded the file and remained to study the page further.

Can you please tell me how to properly implement this functionality? Thanks in advance to all who respond.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Timofeev, 2019-01-24
@EvgMul

You send the form with ajax, a file is generated and saved there, and a link to the file comes in response, you use js to redirect to the file url
document.location = someFileUrl;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question