无法加载下载的内容(CakePHP)

I tried to download the file uploaded in Cake PHP. I could download it but it says 'Failed to load PDF' for PDF and 'The file is corrupted' for docs. I don't know what is wrong in the code.

Here is the brief code.

<?php
header('Content-Length '.$requiredFile['Upload']['size']);
header('Content-type: '.$requiredFile['Upload'['type']]);
header('Content-Disposition: attachment; filename="'.$requiredFile['Upload']['name'].'"');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
echo $requiredFile['Upload']['content'];
?>

$requiredFile is an array:

Array
(
    [Upload] => Array
        (
            [id] => 12
            [tenant_id] => 29
            [name] => Niraj Paudel (CV).pdf
            [type] => application/pdf
            [size] => 126626
            [content] => 'content over here'
  )
);

I would be very grateful if you guys help me fix this issue.

In cakephp you can simply download file sending it in response. Suppose your file is uploaded in webroot/uploads/, below is sample code that will download file.

return $this->response->file(WWW_ROOT.'uploads/yourfilename.pdf', array('download' => true, 'name' => 'yourfilename'));