我用下面的方法做下载文件,但下载下来的文件不对了 $file = fopen($file_name,"rb"); 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 xuzuning(唠叨) 兄:我按你的去试了一下,问题还是没有解决我能把文件下载下来,只是下载下来的文件出问题了,打不开,字节数也比原来的文件增加了, //可以试一下以下代码,IE 和NetScape下均可次数可以用另数一变量保存到据库或文件中 $name=trim(basename($filename)); //$filname 完整绝对路径即可 header("Expires: " . gmdate("D, d M Y H:i:s",time()+24*3600) . " GMT"); header("Cache-Control:"); header("Pragma: cache"); header("Connection: close"); if(strpos(getenv("HTTP_USER_AGENT") , "MSIE")){ header("Content-type: application/download"); header("Content-Disposition: filename=$name"); header("Cache-Control: store, cache, must-revalidate, post-check=0, pre-check=0"); header("Keep-Alive: close"); } else { header("Cache-Control: store, cache, must-revalidate, post-check=0, pre-check=0"); header("Content-type: application/octet-stream"); header("Content-Disposition: attachment;filename=$name"); } $fp=fopen($strFullPath,"rb"); fpassthru($fp); flush(); exit;-------------后缀为下载类型加上下面的代码也可以将认识的类型该为下载提示:Header( "Content-Type: application/x-".$Ream); Header( "Content-Length: ".filesize($FilePath)); //文件大小Header( "Content-Disposition: attachment; filename=".$FileName);//文件名称 php get 方式可以接收html 标签吗? 请帮忙解释一下这段代码的意思,谢谢! zendstudio export问题 如何学PHP?可以不用讲的太细,指个方向也行~ phpmyadmin php网站登陆问题 我看到原碼中有這個&是什麼意思??? php 有没有global object? MYSQL的查询速度问题,一起探讨,对大家都有好处! 这条insert 语句为什么不好用? 请问PHP如何实现这样的功能? mysql一个问题
我能把文件下载下来,只是下载下来的文件出问题了,打不开,字节数也比原来的文件增加了,
$name=trim(basename($filename)); //$filname 完整绝对路径即可
header("Expires: " . gmdate("D, d M Y H:i:s",time()+24*3600) . " GMT");
header("Cache-Control:");
header("Pragma: cache");
header("Connection: close"); if(strpos(getenv("HTTP_USER_AGENT") , "MSIE")){
header("Content-type: application/download");
header("Content-Disposition: filename=$name");
header("Cache-Control: store, cache, must-revalidate, post-check=0, pre-check=0");
header("Keep-Alive: close");
}
else
{
header("Cache-Control: store, cache, must-revalidate, post-check=0, pre-check=0");
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment;filename=$name");
}
$fp=fopen($strFullPath,"rb");
fpassthru($fp);
flush();
exit;
-------------
后缀为下载类型
加上下面的代码也可以将认识的类型该为下载提示:Header( "Content-Type: application/x-".$Ream);
Header( "Content-Length: ".filesize($FilePath)); //文件大小
Header( "Content-Disposition: attachment; filename=".$FileName);//文件名称