500 Error setting headers

Question

I am trying to create a function for downloading a blob file.
the function is hooked with hook "send_headers".

While setting up headers I get 500 internal server error.

 $cType = 'application/octet-stream';
    $headers = array(
        'Pragma'                    => 'public', 
        'Expires'                   => 0, 
        'Cache-Control'             => 'must-revalidate, post-check=0, pre-check=0',                    
        'Content-Description'       => 'File Transfer',
        'Content-Type'              => $cType,
        'Content-Disposition'       => 'attachment; filename="'. $fileName .'"',
        'Content-Transfer-Encoding' => 'binary', 
        'Content-Length'            => $fileLen         
    );

   foreach($headers as $header => $data) {
        header($header, $data); 
   }

where is the mistake?

0
Muneeb 2 months 0 Answers 12 views 0

Leave an answer