I am starting with CakePHP. After a document has been uploaded to my server then the user tries to download it, but the file results corrupt.
What may be causing this to happen? I checked the file through my website's cPanel and it is perfect. This problem only occurs when the user tries to download it.
In my Requirement controller:
function download() {
$file = //here I get the file
$loca = //here I get its location
if (!empty ($file)) {
$file_info = pathinfo($file);
$this->view = 'Media';
$params = array(
'id' => $file,
'name' => $file,
'extension' => $file_info['extension'],
'download' => true,
'path' => APP . WEBROOT_DIR . DS . $loca . DS
);
$this->set($params);
} else {
$this->redirect($this->referer());
}
}
And in my view:
echo $html->link(
'Download', array(
'controller' => 'requirements',
'action' => 'download'
)
);
I have been trying to solve this for a long time. Any help will be appreciated.
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)