【发布时间】:2011-11-05 14:31:21
【问题描述】:
我有一个简单的脚本,允许某人将电影文件下载到他们的设备上。该代码适用于我测试过的所有东西,除了 Andriod。 Android 设备屠宰了名称和文件扩展名。它可能会调用文件 2.qt 或 .bin。为什么会失败?
<?php
if(isset($_GET['filename'])) {
header('Content-Description: File Transfer');
header('Content-Type: movie/quicktime');
header('Content-Disposition: attachment; filename="'.basename($file).'"');
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize("$file"));
ob_clean();
flush();
readfile("$file");
} else {
echo "Link: <a href='test.php?filename=test.mov'>Download Video</a>";
}
?>
【问题讨论】: