HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers10/immoginis.komma.pro/app/controllers/DownloadController.php
<?php

class DownloadController extends BaseController
{
    public function download($fileName = 'document')
    {

        //If file is not present in the request return 404
        if (!\Request::has('location')) return \App::abort('404');

        //Decoded the file name
        $file = base64_decode(\Request::get('location'));

        $ch = curl_init();
        $timeout = 5;
        curl_setopt($ch, CURLOPT_URL, $file);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
        curl_setopt($ch, CURLOPT_HEADER, true);
        $data = curl_exec($ch);

        $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
        //If the code is not 200 abort
        if ($code != 200) return \App::abort('404');
        curl_close($ch);

        //Empty file, abort
        if (strlen($data) == 0) return \App::abort('404');

        header('Content-Description: File Transfer');
        header('Content-Type: application/octet-stream');
        //Set the filename
        header('Content-Disposition: attachment; filename=' . basename($fileName));
        ob_clean();
        flush();
        readfile($file);
        exit;
    }


}