How to read a file using PHP
TAGS: fopen, fread, read file, textfile

if (isset($_POST['doit']))  { 
$viewme = 'file.txt'; 
$file = fopen($viewme, 'r'); 
$string = fread( $file, filesize($viewme) ); 

echo "<TEXTAREA ROWS='24' COLS='80'>"; 
echo $string; 
echo "</TEXTAREA>"; 
<TD>Click here to read file: </TD> 
<TD><INPUT TYPE='submit' NAME='doit' VALUE='Read textfile'></TD> 

This example shows how to read a textfile and present it in a <TEXTAREA> </TEXTAREA>
Simply put the above code in a php file, and call it from your webserver. Remember you need to have a file named “file.txt” for this example.