想做一个文件的下载点,有什么基于PHP类的网站源码程序吗,不想用FTP,想做成WEB形式的,供下载! 10
展开全部
/**
* @desc 提供下载接口
*/
if (file_exists($fpath))
{
$filename = substr($fpath, strrpos($fpath, '/')+1);
$read=fopen($fpath,"r");
$mm_type="application/octet-stream";
header("Cache-Control: public, must-revalidate");
header("Pragma: hack");
header("Content-Type: " . $mm_type);
header("Content-Length: " .(string)(filesize($fpath)) );
header('Content-Disposition: attachment; filename="'.$filename.'"');
echo fread($read,filesize($fpath));
fclose($read);
header("Content-Transfer-Encoding: binary\n");
}
else
{
echo "<script>alert('No this file!!')</script>";
}
echo"<script type='text/javascript'>window.close();</script>";
其中fpath是从提交的表单中获取的文件路径
* @desc 提供下载接口
*/
if (file_exists($fpath))
{
$filename = substr($fpath, strrpos($fpath, '/')+1);
$read=fopen($fpath,"r");
$mm_type="application/octet-stream";
header("Cache-Control: public, must-revalidate");
header("Pragma: hack");
header("Content-Type: " . $mm_type);
header("Content-Length: " .(string)(filesize($fpath)) );
header('Content-Disposition: attachment; filename="'.$filename.'"');
echo fread($read,filesize($fpath));
fclose($read);
header("Content-Transfer-Encoding: binary\n");
}
else
{
echo "<script>alert('No this file!!')</script>";
}
echo"<script type='text/javascript'>window.close();</script>";
其中fpath是从提交的表单中获取的文件路径
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询