Are there alternative approaches or best practices for facilitating file downloads from a server to a local hard drive without direct FTP access?

When direct FTP access is not available, one alternative approach is to use PHP to facilitate file downloads from a server to a local hard drive. This can be achieved by creating a PHP script that reads the file from the server and sends it to the client for download. This way, users can still access and download files from the server without needing FTP access.

<?php
$file = 'path/to/file/on/server.txt';

if (file_exists($file)) {
    header('Content-Description: File Transfer');
    header('Content-Type: application/octet-stream');
    header('Content-Disposition: attachment; filename=' . basename($file));
    header('Expires: 0');
    header('Cache-Control: must-revalidate');
    header('Pragma: public');
    header('Content-Length: ' . filesize($file));
    readfile($file);
    exit;
} else {
    echo 'File not found.';
}
?>