<?php

namespace App\Controllers;

class FileController {

    public function show($folder, $filename) {
        $filePath = __DIR__ . '/../../../uploads/' . $folder . '/' . $filename;

        if (!file_exists($filePath)) {
            http_response_code(404);
            die("Archivo no encontrado.");
        }

        $mimeType = mime_content_type($filePath);
        header("Content-Type: $mimeType");
        header("Content-Length: " . filesize($filePath));
        readfile($filePath);
        exit;
    }
}


