文件路径名表示问题

steel06 2002-05-20 08:33:24
$file_dir = "d:\\homework\\".$tit."\\";
$tit是一字符窜变量

请问这种表示正确吗?
...全文
89 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
benjamin9 2002-05-20
  • 打赏
  • 举报
回复
另外,在使用header的时候,应该保证前面没有任何HTML标记元素的存在.
darzui 2002-05-20
  • 打赏
  • 举报
回复
在header之前有一句echo $file_dir;把它去掉
使用header的时候,应该保证之前页面上没有输出任何内容(包括空行)
steel06 2002-05-20
  • 打赏
  • 举报
回复
我写的是一个文件下载的程序:
<?
$w=strtok($title,".");
$tit=$w;
echo $tit;
echo $title;
$file_name ="$title";
$file_dir = "d:\homework\\";
$file_dir=$file_dir.$tit."\\";

echo $file_dir;
$file_dir=addslashes($file_dir);
if (!file_exists($file_dir . $file_name)) { //检查文件是否存在
echo "文件找不到";
exit;
} else {
$file = fopen($file_dir . $file_name,"r"); // 打开文件
// 输入文件标签
Header("Content-type: application/octet-stream");
Header("Accept-Ranges: bytes");
Header("Accept-Length: ".filesize($file_dir . $file_name));
Header("Content-Disposition: attachment; filename=" . $file_name);
// 输出文件内容
echo fread($file,filesize($file_dir . $file_name));
fclose($file);
exit;}
?>
错误信息如下:
Warning: Cannot add header information - headers already sent by (output started at c:\apache\htdocs\ide\data\download.php:4) in c:\apache\htdocs\ide\data\download.php on line 18

Warning: Cannot add header information - headers already sent by (output started at c:\apache\htdocs\ide\data\download.php:4) in c:\apache\htdocs\ide\data\download.php on line 19

Warning: Cannot add header information - headers already sent by (output started at c:\apache\htdocs\ide\data\download.php:4) in c:\apache\htdocs\ide\data\download.php on line 20

Warning: Cannot add header information - headers already sent by (output started at c:\apache\htdocs\ide\data\download.php:4) in c:\apache\htdocs\ide\data\download.php on line 21
请问这是什么错误了?
foolfish 2002-05-20
  • 打赏
  • 举报
回复
可以的

正确.
steel06 2002-05-20
  • 打赏
  • 举报
回复
急……!!!

21,886

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧