F::download PHP Method

download() public static method

* Automatically sends all needed headers for the file to be downloaded and echos the file's content
public static download ( $file, $name = null )
$file The root to the file
$name Optional filename for the download
    public static function download($file, $name = null)
    {
        // stop the download if the file does not exist or is not readable
        if (!is_file($file) || !is_readable($file)) {
            return false;
        }
        header::download(array('name' => $name ? $name : f::filename($file), 'size' => f::size($file), 'mime' => f::mime($file), 'modified' => f::modified($file)));
        die(f::read($file));
    }