<?php

use \Illuminate\Support\Facades\File;
use Mtc\Shop\Assessment\Assessment;

$path = '../../../';

require_once  $path . 'core/includes/header.inc.php';

$answer = \Mtc\Shop\Assessment\Answer::query()->find(request('id'));
if (!$answer) {
    http_response_code(404);
    exit;
}

$file_path = storage_path('app/' . Assessment::UPLOAD_PATH . '/' . $answer->answer);
if (File::exists($file_path) === false) {
    http_response_code(404);
    exit;
}

$file = File::get($file_path);
$mime = File::mimeType($file_path);
header("Content-type: " . $mime);
echo $file;