CodeIgniter Forums
v4.4.4 download not working, v4.1.1 does work - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: v4.4.4 download not working, v4.1.1 does work (/showthread.php?tid=89251)



v4.4.4 download not working, v4.1.1 does work - Kaosweaver - 01-30-2024

Code:
public function file_view($year, $employee_number, $file_type) {


        if ($employee_number != 0) {
            $wellnessModel = new \App\Models\WellnessAttestationModel();
            $result = $wellnessModel->findLastYears($employee_number, $year);
        } else {
            $benefitProgramModel = new \App\Models\BenefitProgramModel();
            $result = $benefitProgramModel->find($year);
        }
        if (empty($result)){
            return "No file to download.";
            die();
        }
        if ($file_type == "CCCL") {
            $file_path = trim($result['Cessation_Completion_Cert_Location']);
        } else if ($file_type == "CPFL") {
            $file_path = trim($result['Cessation_Proof_Enrollment_Location']);
        } else if ($file_type == "PAL") {
            $file_path = trim($result['Physician_Affidavit_Location']);
        } else if ($file_type == "PALF") {
            $file_path = trim($result->Physician_Affidavit_Template_Location);
        } else {
            return false;
        }
        return $this->response->download($file_path, NULL, TRUE);
    }

The code is the same, we have both v4.1.1 and v4.4.4 running using the same server/database - the v4.1.1 will download the file while the v4.4.4 just loads a blank page off the clicked link.  The file is there, the file was uploaded on v4.4.4 (which I was happy about). I checked the logs, no errors. I'm not getting a routing error either.

We did add specific routes (no idea if it matters):
Code:
$routes->group('wellness', static function ($routes) {
    // GET routes, alphabetized
   
    $routes->get('file_view/(:any)', 'Wellness::file_view/$1');
}

Hoping someone has encountered this and I'm just missing something obvious.  This is on a Windows server.


RE: v4.4.4 download not working, v4.1.1 does work - Kaosweaver - 01-30-2024

So, totally my fault. The third parameter was being made into lower case, which then failed on the if statement for comparison returning nothing on the else statement.


RE: v4.4.4 download not working, v4.1.1 does work - ozornick - 01-30-2024

Errors in apache logs or writable/logs?