下载
来源:互联网 发布:网络扫描仪怎么添加 编辑:程序博客网 时间:2024/04/30 05:13
<?php
$rootPath=$_SERVER['DOCUMENT_ROOT'];
$filePath = $_GET [filePath];
if ($filePath == "")
return null;
else{
$servername = $_SERVER["HTTP_HOST"];
$needstr="/^(http:\/\/)?([^\/]+)/i";
if(preg_match_all($needstr,$filePath,$allpras)){
$realpath = str_replace($allpras['0'],'',$filePath);
}elseif(preg_match_all("/^(https:\/\/)?([^\/]+)/i",$filePath,$allpras)){
$realpath = str_replace($allpras['0'],'',$filePath);
}else{
$realpath=$filePath;
}
}
// 得到附件的名称
function GetAttachmentFileName($filePath) {
global $empire, $dbtbpre;
$strarr = explode ( '/', $filePath );
$gotfilename = end ( $strarr );
if ($gotfilename != "") {
// 取得名字
$sql = $empire->fetch1 ( "select name from your table'" );
return $sql ['name'];
} else {
return $filePath;
}
}
// 得到要保存的文件名
$realname = GetAttachmentFileName ( $filePath );
//$rootPath = dirname ( dirname ( dirname ( dirname ( dirname ( __FILE__ ) ) ) ) );
$file = $rootPath . $realpath;
//echo $file;die;
if (file_exists ( $file )) {
header ( 'Content-Description: File Transfer' );
header ( 'Content-Type: application/octet-stream' );
header ( 'Content-Disposition: attachment; filename=' . $realname );
header ( 'Expires: 0' );
header ( 'Cache-Control: must-revalidate' );
header ( 'Pragma: public' );
header ( 'Content-Length: ' . filesize ( $file ) );
ob_clean ();
flush ();
readfile ( $file );
exit ();
} else {
return null;
}
?>
$rootPath=$_SERVER['DOCUMENT_ROOT'];
$filePath = $_GET [filePath];
if ($filePath == "")
return null;
else{
$servername = $_SERVER["HTTP_HOST"];
$needstr="/^(http:\/\/)?([^\/]+)/i";
if(preg_match_all($needstr,$filePath,$allpras)){
$realpath = str_replace($allpras['0'],'',$filePath);
}elseif(preg_match_all("/^(https:\/\/)?([^\/]+)/i",$filePath,$allpras)){
$realpath = str_replace($allpras['0'],'',$filePath);
}else{
$realpath=$filePath;
}
}
// 得到附件的名称
function GetAttachmentFileName($filePath) {
global $empire, $dbtbpre;
$strarr = explode ( '/', $filePath );
$gotfilename = end ( $strarr );
if ($gotfilename != "") {
// 取得名字
$sql = $empire->fetch1 ( "select name from your table'" );
return $sql ['name'];
} else {
return $filePath;
}
}
// 得到要保存的文件名
$realname = GetAttachmentFileName ( $filePath );
//$rootPath = dirname ( dirname ( dirname ( dirname ( dirname ( __FILE__ ) ) ) ) );
$file = $rootPath . $realpath;
//echo $file;die;
if (file_exists ( $file )) {
header ( 'Content-Description: File Transfer' );
header ( 'Content-Type: application/octet-stream' );
header ( 'Content-Disposition: attachment; filename=' . $realname );
header ( 'Expires: 0' );
header ( 'Cache-Control: must-revalidate' );
header ( 'Pragma: public' );
header ( 'Content-Length: ' . filesize ( $file ) );
ob_clean ();
flush ();
readfile ( $file );
exit ();
} else {
return null;
}
?>
0 0
- 下载
- 下载
- 下载
- 下载
- 下载???
- 下载
- 下载
- 下载
- 下载
- 下载
- 下载
- 下载
- 下载
- 下载
- 下载
- 下载
- 下载
- 下载
- Eclipse使用
- leetcode - N-Queens II
- UITabBarController使用详解
- 高性能服务器架构(High-Performance Server Architecture)
- MPI并行编程传递多维数组需要注意的若干问题
- 下载
- UINavigationController使用详解
- java通过axis访问.net webService 简单例子
- 计算两个字符串的距离
- 南京林业大学“未来之星”第六届程序设计大赛(决赛)试题D 参考代码
- 回看存储过程
- js定时换图片效果
- ECMA 字符串操作 方法
- (leetcode 2) Max Points on a line