hi
the below code is used to read a uploaded file and print the first three lines in a document,
it is working fine in a txt file .i have written the else part for doc file....it is working but junk values are also getting printed
<?php
$lines=file('http://www.wb.com/judson.doc');
$lin = "/home/wb/public_html/judson.doc";
$extension = array_pop(explode(".", $lin));
if (($extension == "txt"))
{
foreach ($lines as $line_num => $line) {
if ($line_num >=0 && $line_num <= 3) {
echo "<a href='http://www.wb.com/judson.txt'>" . htmlspecialchars($line) . "</a><br />\n";
}
}
}
else
{
$fileHandle = fopen($lin, "r");
$line = @fread($fileHandle, filesize($lin));
$lines = explode(chr(0x0D),$line);
$outtext = "";
foreach ($lines as $line_num => $line) {
if ($line_num >=0 && $line_num <= 3) {
$line = preg_replace("/[^a-zA-Z0-9\s\,\.\-@\/\_\(\)]/","",$line);
echo "<a href='http://www.wb.com/judson.doc'>" .$line. "</a><br />\n";
}
}
}?>