读取文件的问题

ezhou 2003-06-18 10:05:26
页面与控制分离,html文件中有如下语句:
...
<tr>
<td><FONT color = blue >Please choose the data file you want to submit:</FONT><br><br>
<input type="file" name="in_file" size="20"><input type="submit" value="Submit" name="submit"></td>
</tr>
...
php文件中有如下语句:
...
$in_file = mysql_escape_string($HTTP_GET_VARS['in_file']);
...
if(file_exists($in_file){ //该句出现问题
$fp = fopen($in_file,"r");
...
}

难道是$in_file没有得到么?
请帮忙看看!
...全文
33 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
ezhou 2003-06-19
  • 打赏
  • 举报
回复
其实我是想在后台直接对文件进行操作,感觉我现在采用的方法不是太合理,不知道有没有比较好的方法,最好能给出示范代码,谢谢了。
bonniewater 2003-06-19
  • 打赏
  • 举报
回复
<form name="form1" method="post" action="accept.php" >
<input type="file" name="in_file" size="20"><input type="submit" value="Submit" name="submit"></td></form>

accpet.php
<?php
if(file_exists($in_file_name))
{
$text=file($in_file_name);
foreach($text as $key=>$val)
{
$str.=$val;
}
}
echo $str;
?>
$str就是文件的内容了
ezhou 2003-06-19
  • 打赏
  • 举报
回复
那临时目录在什么位置呢?
programdolt 2003-06-19
  • 打赏
  • 举报
回复
文件上传后文件名变量是 $in_file_name,不是$in_file了。
linuxx 2003-06-18
  • 打赏
  • 举报
回复
文件传上去之后在临时目录里,不在当前目录,
你的目录名也不对。
linuxx 2003-06-18
  • 打赏
  • 举报
回复
<form name="form1" method="post" action="。。" enctype="multipart/form-data">



$in_file = mysql_escape_string($_FILES["in_file"]["name"]);

21,886

社区成员

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

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