<?php
$file = "a.js";
$filename = basename($file);
header("Content-type: application/octet-stream");
$agent = $_SERVER["HTTP_USER_AGENT"];
$encoded_filename = rawurlencode($filename);
if (preg_match("/MSIE/", $agent)) {
header('Content-Disposition: attachment; filename="' . $encoded_filename . '"');
} else if (preg_match("/Firefox/", $agent)) {
header("Content-Disposition: attachment; filename*=\"utf8''" . $filename . '"');
} else {
header('Content-Disposition: attachment; filename="' . $filename . '"');
}
header("Content-Length: " . filesize($file));
readfile($file);
?>
PHP 下载文件
最新推荐文章于 2023-01-30 10:49:14 发布