php代码
部分功能简介:商品收藏夹功能热门商品最新商品分级价格功能自选风格打印结算页面内部短信箱商品评论增加上一商品,下一商品功能增强商家提示功能友情链接用户在线统计用户来访统计用户来访信息用户积分功能广告设置用户组分类邮件系统后台实现更新用户数据系统图片设置模板管理CSS风格管理申诉内容过滤功能用户注册过滤特征字符IP库管理及来访限制及管理压缩,恢复,备份数据库功能上传文件管理商品类别管理商品添加/修改/
0
/*
* $filepath 文件路径
* $newfilename 下载时的命名
* download('/abc.xls','abc教学');
* 下载下来的文件将是abc教学.xls
*/
function download($filepath,$newfilename){
$id = intval($_GET['id']);
$db = model('tool');
$tool = $db->where('id='.$id)->find();
if(!$tool) $this->error('未找到您要查看的工具');
$ua = $_SERVER["HTTP_USER_AGENT"];
$pathinfo = pathinfo($filepath);
$newfilename = $newfilename.'.'.$pathinfo['extension'];
$file = fopen( $filepath ,"r");
header('Content-Type: application/octet-stream');
header("Accept-Ranges: bytes");
header("Accept-Length: ".filesize($filepath));
if (preg_match("/MSIE/", $ua)) {
header('Content-Disposition: attachment; filename="' . rawurlencode($newfilename) . '"');
} else if (preg_match("/Firefox/", $ua)) {
header('Content-Disposition: attachment; filename*="utf8\'\'' . $newfilename . '"');
} else {
header('Content-Disposition: attachment; filename="' . rawurlencode($newfilename) . '"');
}
echo fread($file, filesize($filepath));
//$db->where('id='.$id)->data($update)->update();
fclose($file);
}
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号