Ok. jeg har undersøgt lidt nu efter jeg har noget at gå efter. Så har jeg fundet denne...
Så det skal jeg lige arbejde lidt videre med...
https://mohammadg.com/programming/simple-php-file-download-script/<?php
/*
* Download File script
* Aurthor: Mohammad Ghasembeigi
* Url:
https://mohammadg.com * Usage: /download.php?file=XXXX
*
*/
ignore_user_abort(true);
set_time_limit(0); // disable the time limit for this script
if (isset($_GET[‘file’])) {
$path_parts = pathinfo($_GET['file']);
$file_name = $path_parts['basename'];
$path_to_filevault_dir = "/filevault";
//Build absolute file path
$path_to_file = $path_to_filevault_dir . '/' . $file_name;
//Check if file exists
if (!file_exists($path_to_file)) {
print '<div>Invalid file specified. Please notify the webmaster if you think this is a mistake.</div>';
exit(1);
}
//Check if file is readable
if (!is_readable($path_to_file)) {
print "An error has occurred. Please notify the webmaster.";
exit(1);
}
# detect MIME type (
http://stackoverflow.com/a/32092523/1800854)
$finfo = finfo_open(FILEINFO_MIME_TYPE);
header('Content-Type: ' . finfo_file($finfo, $path_to_file));
$finfo = finfo_open(FILEINFO_MIME_ENCODING);
header('Content-Transfer-Encoding: ' . finfo_file($finfo, $path_to_file));
header('Content-disposition: attachment; filename="' . basename($path_to_file) . '"');
readfile($path_to_file);
}
else {
print "'file' parameter is missing and is required.";
exit(1);
}
?>