<html>
<head><title>读取文件</title></head>
<body bgcolor=#d6dff7>
<img src=index_10.jpg><center>
<h3>选择文件</h3>
<form action="Example2_3_1.php" method="post">
<input type=file name=name1 value=浏览><br>
<input type=submit value="显示文件内容">
</form>
</body>
</html>
上边是HTML页面,提交到Example2_3_1.php进行显示处理
<html>
<head><title>读取文件</title></head>
<body bgcolor=#d6dff7>
<img src=index_10.jpg><center>
<h3>内容显示</h3>
<form >
<textarea cols="85" rows="10" name="name1">
<?php
$str=$_POST['name1'];
$filename = $str;
$fe = fopen($filename,'rt');
while (!feof($fe))
{
$text=fgets($fe);
echo $text;
}
fclose($fe);
?>
</textarea>
</form>
</body>
</html>
这样你所要打开的文本文件,就能显示出来,大家可以试试。。。。