$file_name = "m_files1.zip";
$fullPath = WWW_ROOT . 'zip_files' . DS . $file_name;
if (file_exists($fullPath)) {
echo "<br>Found";
return $this->response
->withHeader('Content-Type', $mime)
->withHeader('Content-Transfer-Encoding', 'Binary')
->withHeader('Content-Disposition', 'attachment;filename="' . $file_name . '"')
->withHeader('Content-Description', 'File Transfer')
->withHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0')
->withHeader('Cache-Control', 'public')
->withHeader('Expires', '0')
->withHeader('Pragma', 'public')
->withHeader('Content-Length', filesize($fullPath))
->withFile(
$fullPath,
array('download' => true, 'name' => $file_name)
);
}
Don’t why after download zip file not open.
But if i download through direct file link, then that zip open perfectly.
what is the issue, please help me to fix.
I’m using cakephp3.8 .