php代码
电子手机配件网站源码是一个响应式的织梦网站模板,软件兼容主流浏览器,且可以在PC端和手机端中进行浏览。模板包含安装说明,并包含测试数据。本模板基于DEDECms 5.7 UTF-8设计,需要GBK版本的请自己转换。模板安装方法:1、下载最新的织梦dedecms5.7 UTF-8版本。2、解压下载的织梦安装包,得到docs和uploads两个文件夹,请将uploads里面的所有文件和文件夹上传到你的
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号