S
S
Sergey Beloventsev2018-09-19 16:35:00
Yii
Sergey Beloventsev, 2018-09-19 16:35:00

Why are the headers not overwritten?

Actually, here is the code of the controller, I think it will be clear

public function actionView($id)
    {
        Yii::$app->response->headers->set('Content-Type','application/pdf');
        $documentSave=$this->findModel($id);

        return $this->documentService->getPDF($documentSave->documents_id,$documentSave->order,$documentSave);

    }

Actually, I get the title like this

Content-type 'text/html; charset=UTF-8'

and if I do it by standard means, but I get the error Cannot modify header information - headers already sent by why?
header('Content-Type: application/pdf');

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question