Answer the question
In order to leave comments, you need to log in
How to navigate to a new page and download a yii2 file at the same time?
My code snippet, but if the first if is not executed, the transition to the desired page does not occur, but only the file is downloaded. How to get around this?
if($this->flag == 1){
Yii::$app->mailer->compose()
->setTo($this->email)
->setFrom(['@gmail.com' => Yii::$app->params['senderName']])
->setReplyTo([$this->email => $this->fromPerson])
->setSubject("Ваш конверт")
->attachContent($pdf->Output('', 'S'), ['fileName' => 'pdfName.pdf', 'contentType' => 'application/pdf'])
->send();
}
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename=' . 'enelope.pdf');
exit($pdf->Output('', 'S')); // работает не коорректно, не переводит на нужную страницу
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question