in Education by
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)

1 Answer

0 votes
by
hmm im not really sure about this is the problem... but the doc about the Media Views says: name - The name allows you to specify an alternate file name to be sent to the user. Specify the name without the file extension. and you are not adding the mime type neither... try adding it Good Luck

Related questions

0 votes
    Closed. This question is opinion-based. It is not currently accepting answers. Want to improve this question ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Aug 1, 2022 in Education by JackTerrance
0 votes
    ____________ work in background & keeps on downloading other malicious programs when the system is online. (a) ... -Cyber Security:,Cyber Security-Jobs:,Cyber Security Applications...
asked Nov 1, 2021 in Education by JackTerrance
0 votes
    The disk controller uses ________ at each sector to ensure that the data is not corrupted on data ... Database Interview Questions and Answers for Freshers and Experience...
asked Oct 11, 2021 in Education by JackTerrance
0 votes
    I'm using ActionMailer in my application and I want to use localized views for email templates. It seems ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 10, 2022 in Education by JackTerrance
0 votes
    I'm developing my app with electron and I'm using electron-updater to show a window that asks to ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 20, 2022 in Education by JackTerrance
0 votes
    the————button is used to restart the downloading of a Web page A)Refresh B)Home Select the correct answer from above options...
asked Dec 19, 2021 in Education by JackTerrance
0 votes
    The reflection coefficient of a wave travelling through two media having electric intrinsic impedances ... ,electromagnetic theory engineering physics,electromagnetic theory nptel...
asked Nov 6, 2021 in Education by JackTerrance
0 votes
    I am trying to write my below pinging script results into the Text file, but I am getting an error message. ... object is not iterable Select the correct answer from above options...
asked Jan 11, 2022 in Education by JackTerrance
0 votes
    What does MMORPG stand for? 1) Multi-media online role played game 2) Massively multiplayer online role playing ... penetration of gas Select the correct answer from above options...
asked Dec 14, 2021 in Education by JackTerrance
0 votes
    The critical angle for two media of refractive indices of medium 1 and 2 given by 2 and 1 ... proposed by,electromagnetic theory engineering physics,electromagnetic theory nptel...
asked Nov 6, 2021 in Education by JackTerrance
...