Display file contents to text area

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Blaydo
Forum Newbie
Posts: 14
Joined: Fri Jun 06, 2003 4:31 pm
Location: Michigan, USA
Contact:

Display file contents to text area

Post 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?
junrey
Forum Newbie
Posts: 12
Joined: Thu May 09, 2002 9:53 pm
Location: Cebu, Philippines
Contact:

Post by junrey »

Yes you can

Regards,
Junrey
Drachlen
Forum Contributor
Posts: 153
Joined: Fri Apr 25, 2003 1:16 am

Post 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..
Blaydo
Forum Newbie
Posts: 14
Joined: Fri Jun 06, 2003 4:31 pm
Location: Michigan, USA
Contact:

Post 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...
User avatar
nielsene
DevNet Resident
Posts: 1834
Joined: Fri Aug 16, 2002 8:57 am
Location: Watertown, MA

Post by nielsene »

try doing

Code: Select all

<textarea name="feedback">
<?php
htmlentities(file_get_contents($file))
?>
</textarea>
Blaydo
Forum Newbie
Posts: 14
Joined: Fri Jun 06, 2003 4:31 pm
Location: Michigan, USA
Contact:

Post 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.
Post Reply