后缀为下载类型
加上下面的代码也可以将认识的类型该为下载提示: Header( "Content-Type: application/x-".$Ream);
Header( "Content-Length: ".filesize($FilePath)); //文件大小
Header( "Content-Disposition: attachment; filename=".$FileName);//文件名称
加上下面的代码也可以将认识的类型该为下载提示: Header( "Content-Type: application/x-".$Ream);
Header( "Content-Length: ".filesize($FilePath)); //文件大小
Header( "Content-Disposition: attachment; filename=".$FileName);//文件名称
解决方案 »
- 安装配置好phpmyadmin后输入http://localhost/phpMyAdmin-3.5.1-all-languages/没有弹出登陆容窗口
- PHP参数后怎么无法加 "_" 啊
- 用php写的简单的文件上传代码,文件不能被上传,错误信息如下,请高手看是什么原因
- 怎么我键入控制器名/action 出现 object not found
- 新手,写个日期正则式,没写对,求给提示
- 谁能发个IP对应地址的IP数据库啊
- 请问MATCH (co1,co2) AGAINST ('$a')怎样使用?
- 刚整了个PHP留言簿,请大伙给扔扔砖头。
- 怎么样修改mysql安装后的root空密码?
- PHP可以支持UDP或是其它方式的通讯吗?
- PHPMyAdmin的问题
- 我是第一次发帖子!请各位关照,谢谢!我在做提交表单的时候,遇到了一个莫名其妙的问题,不知各位能不能给解决一下!
还有一点就是这些文件要是能够下载的,象asp文件等一般是不能直接下载的,如果你要让别人去下载它们,你可以先打个包再下。
另外看你要下载什么文件,如果是系统已知程序就会在IE中直接打开。例如.doc.
<?
//=============== program description ===============
//
//程序目的:下载文件
//Written By LinShicheng. (email:[email protected])
//
//===================================================function get_ext_name($file){
$part= explode('.',$file );
$ext = $part[count($part) - 1];
return ($ext);
}
function read_from_file ( $file ){
if ( ! file_exists ( $file ) ){
return ( FALSE );
}
$fp = fopen ( $file, "r" );
if ( ! $fp ){
return ( FALSE );
}
flock ( $fp, LOCK_SH );
$data = fread ( $fp, filesize ( $file ) );
fclose ( $fp );
return ( $data );
}
if (!strstr($file,"upload")){
echo "<script language='Javascript'>";
echo "window.alert('出错啦,您非法访问!');";
echo "window.close()";
echo "</script>";
exit;
}
if (strstr($file,"..")){
echo "<script language='Javascript'>";
echo "window.alert('出错啦,您非法访问!');";
echo "window.close()";
echo "</script>";
exit;
}
$filename= basename($file);
$ext = get_ext_name($filename);
$mime_type=(USR_BROWSER_AGENT=='IE'||USR_BROWSER_AGENT=='OPERA')?'application/octetstream':'application/octet-stream';header ('Content-Type:'.$mime_type);
$content_disp =(USR_BROWSER_AGENT =='IE')?'inline':'attachment';
header ('Content-Disposition:'.$content_disp.';filename="'.$filename.'"');
header ('Pragma: no-cache');
header ('Expires: 0');
$content =read_from_file($file);
echo $content;
?>
没人看啊