Page 1 of 1

Display file contents to text area

Posted: Fri Jun 20, 2003 7:39 pm
by Blaydo
Hey guys, i was just wondering if it is possible to "display the contents" of say, an html document, and have it print the source code to a text area? Or display the contents of a txt file?

Posted: Fri Jun 20, 2003 8:44 pm
by junrey
Yes you can

Regards,
Junrey

Posted: Fri Jun 20, 2003 8:58 pm
by Drachlen
Well wasn't that the most helpful comment I've ever seen on this forum junrey. Blaydo, I'm trying to figure out right now how to place it into a text box, but it appears to just write the include statement, rather than include it. But if you want to just make it appear on a seperate page, this should work for you:

Code: Select all

<?php
$file = 'the files url';

include($file);

?>
I'll reply again if I figure something out for placing it in a textarea..

Posted: Fri Jun 20, 2003 10:09 pm
by Blaydo
thanks :)

well i figured out a way to do it, calling php from an html text area....

Code: Select all

<?php

/**
 * Test print file to page
 * Blaydo *
 * @version $Id$
 * @copyright 2003 
 **/

$file = 'http://clansite.blaydo.gamehosts.com/WS_FTP.LOG'; 
?>
<html>
<BR>
<textarea name="feedback" ROWS="9" COLS="45"><?php include($file); ?></textarea> 
</html>
However, it errors and says this...
<b>Warning</b>: main(): stream does not support seeking in <b>/home/doc/public_html/clansite/what.php</b> on line <b>14</b>

so something isnt working, and its displaying a text file with html tags as well...

Posted: Fri Jun 20, 2003 10:19 pm
by nielsene
try doing

Code: Select all

<textarea name="feedback">
<?php
htmlentities(file_get_contents($file))
?>
</textarea>

Posted: Fri Jun 20, 2003 11:01 pm
by Blaydo
well i got it workin for what i needed.... i had a php page display, then copy itself to a .html document, then access that and display the html in a text area. it works fine for me, but i can see if you dont need html tags to use that method above... cuz thats what it means right? eliminate html tags or somethin?

btw, thanks for all of you who helped.