php文件流下载不支持虚拟目录

来源:百度知道 编辑:UC知道 时间:2024/06/07 13:10:15
我的下载源码如下:可以下载实际目录的文件,换成虚拟目录就会出错!

<?php
download("downtest/可.rar");
function download($_file)
{
$file = fopen($_file,"r");
Header("Content-type: application/octet-stream");
Header("Accept-Ranges: bytes");
Header("Accept-Length: ".filesize($_file));
Header("Content-Disposition: attachment; filename=" . basename($_file));
echo fread($file,filesize($_file));
fclose($file);
}

?>

<?php
download("downtest/可.rar");
function download($_file)
{
$file = fopen($_file,"r");
Header("Content-type: application/octet-stream");
Header("Accept-Ranges: bytes");
Header("Accept-Length: ".filesize($_file));
Header("Content-Disposition: attachment; filename=" . basename($_file));
echo fread($file,filesize($_file));
fclose($file);
}

?>