<?php
$api = "
https://example.com/";
$file = __DIR__ . "/cache/" . md5($_GET['file']);
$real = realpath($file);
if($real == "" || !file_exists($real)) {
$data = file_get_contents("{$api}{$_GET['file']}");
if(strlen($data) > 0) {
@
file_put_contents($file, $data);
} else {
exit("Cannot fetch data!");
}
}
$real = realpath($file);
$fi = new finfo(FILEINFO_MIME_TYPE);
$mime = $fi->file($real);
$file_name = basename($real);
Header("Content-Type: {$mime}");
Header("Content-Length: " . filesize($real));
Header("Content-Disposition: attachment; filename={$file_name}");
readfile($real);
exit;
随手写的,不知道能用不(