<?php
//Part of auto_include.php Start
//ROOT Var Start
$root = $_SERVER['DOCUMENT_ROOT'];
//ROOT Var End
//DB Start
include($root.'/engine/conn_db.php');
//DB End
//Part of auto_include.php End
$file_key = $_GET['file_key'];
if($result = $db->query("SELECT * FROM `files` WHERE `id_key`='{$file_key}'")) {
while($row = $result->fetch_object()) {
$file_key = $row->id_key;
$file_name = $row->name;
$file_size = $row->size;
$file_mime = $row->mime;
$file_path_rel = '/get/'.$file_key.'/'.$file_name;
$file_path = $root.$file_path_rel;
$file_exist = true;
}
}
if($file_exist == false) die();
//If Get
header('Accept-Ranges: bytes');
header('Cache-Control: max-age=0, no-store');
header('Connection: Keep-Alive');
header("Content-Length: $file_size");
header("Content-Type: $file_mime");
header('Keep-Alive: timeout=10, max=100');
header('Server: Apache');
//If Load
header("Content-Type: application/octet-stream");
header("Content-Length: $file_size");
header("Content-Disposition: attachment; filename=\"$file_name\"");
readfile($file_path);
?>
我正在尝试将文件返回给用户以便在浏览器中查看,如果可能的话,包括mp4视频。它有效,但长视频(约50分钟)的速度慢。通过直接链接显着加快它们的速度,然后在网络选项卡(检查器)中,它使用各种内容范围标题加载了多次。
如果使用了其他标头(在//Load
下),则在后台进行文件下载。我可以在完成下载之后看到保存窗口,就像在mega.nz上一样。