">
当前位置:Gxlcms > PHP教程 > 各位大神求救啊!!!!!!!!!!!!

各位大神求救啊!!!!!!!!!!!!

时间:2021-07-01 10:21:17 帮助过:6人阅读

做个文件系在 简单谢了个页面总是出错 这个是下载文件的列表文件
点击下载


点击下载


点击下载


点击下载




这个是接受数据文件 require_once 'fileDown.class.php';
header("content-type:text/html;charset=utf-8");
$filename=$_REQUEST['filename'];
$f1=new FILEDOWN();
$f1->file($filename,"http/images/");

?>



这个是class文件
class FILEDOWN{
public function file($file_name,$file_sub_dir){
$file_name=iconv("utf-8","gb2312",$file_name);
$file_path=$_SERVER['DOCUMENT_ROOT'].$file_sub_dir.$file_name;
if(!file_exists($file_path)){
echo "文件不存在";
return;
}
$fp=fopen($file_path,"r");
$file_size=filesize($file_path);
header("Content-type:application/octet-stream");
header("Accept-Ranges:bytes");
header("Content-Disposition:attachment;filename=".$file_name);
$buffer=1024;
$file_count=0;
while(!feof($fp) && ($file_size-$file_count>0)){
$file_data=fread($fp,$buffer);
$file_count+=$buffer;
echo $file_data;
}
fclose($fp);
}
}
?>



回复讨论(解决方案)

Notice: iconv(): Detected an illegal character in input string in D:\Program Files\wamp\apache\htdocs\http\fileDown.class.php on line 4
文件不存在 总是报这个错误 查了半天 真不知道怎么弄了 编码问题

求各位大神帮忙看看

echo $filename; 是什么值

人气教程排行