是个网盘程序,用提取码来下载文件,upload功能正常,但下载的时候出现错误
提示:
Warning: Cannot modify header information - headers already sent by (output started at /home/j/download.php:1) in /home/j/download.php on line 24Warning: Cannot modify header information - headers already sent by (output started at /home/j/download.php:1) in /home/j/download.php on line 25
download.php 文件为(不知为什么,附件不能上传)<?php
require 'config.php';
require 'db.php';
$db=new db;
$db->connect($dbhost, $dbuser, $dbpwd, $dbname);
$Mcncc=$_POST['Mcncc'];
$res=$db->query("select count(*) from list where code='".$Mcncc."'");
$count=$db->fetch_row($res);
if(!$count[0])
{
echo "Have no this Code";
}
else
{
$sql="select file from list where code='".$Mcncc."'";
$res=$db->query($sql);
$tmp=$db->fetch_row($res);
$filename=$uploaddir.$tmp[0];
$realname=substr($tmp[0],0,-5);
$str='Content-Disposition: attachment; filename="'.$realname.'"';
header("Content-type: application/force-download");
header($str);
readfile($filename);
}
?>
请问,哪里出现了错误?该怎么解决呢?
提示:
Warning: Cannot modify header information - headers already sent by (output started at /home/j/download.php:1) in /home/j/download.php on line 24Warning: Cannot modify header information - headers already sent by (output started at /home/j/download.php:1) in /home/j/download.php on line 25
download.php 文件为(不知为什么,附件不能上传)<?php
require 'config.php';
require 'db.php';
$db=new db;
$db->connect($dbhost, $dbuser, $dbpwd, $dbname);
$Mcncc=$_POST['Mcncc'];
$res=$db->query("select count(*) from list where code='".$Mcncc."'");
$count=$db->fetch_row($res);
if(!$count[0])
{
echo "Have no this Code";
}
else
{
$sql="select file from list where code='".$Mcncc."'";
$res=$db->query($sql);
$tmp=$db->fetch_row($res);
$filename=$uploaddir.$tmp[0];
$realname=substr($tmp[0],0,-5);
$str='Content-Disposition: attachment; filename="'.$realname.'"';
header("Content-type: application/force-download");
header($str);
readfile($filename);
}
?>
请问,哪里出现了错误?该怎么解决呢?
解决方案 »
- 哪位能给我一段PHP接收复选框(checkbox)的值的例子
- php+ajax 实现顶一下功能的问题。求助!!!
- php在页面之间传递select标签值!
- 想del一筆資料,怎在button加上確認
- 假如别人正在访问一个文件index.html,而我正在后台生成该静态页面,用的是fopen,请问会出现无法生成的情况吗?
- 求一个powerpoint做的flash教程啊?
- 定义一个文件名变量的 问题(在线等)
- 如何输出今天是一年的第几个星期,谢谢
- 关于session的问题!
- 我用phpstudy安装的iis+php5.3n。为什么PHP Notice: Undefined variable。脚本就会中断执行?
- php购物系统,有分相送
- 基于php+mysql的数据显示分页算法
是 line 21 line 22