icefire Posted June 21, 2010 Share Posted June 21, 2010 Hi! How can i call a txt file to show in <textarea> box ? Thank you Quote Link to comment https://forums.phpfreaks.com/topic/205458-call-a-txt-file/ Share on other sites More sharing options...
gizmola Posted June 21, 2010 Share Posted June 21, 2010 Did you look at fopen() in the php manual? Quote Link to comment https://forums.phpfreaks.com/topic/205458-call-a-txt-file/#findComment-1075181 Share on other sites More sharing options...
icefire Posted June 21, 2010 Author Share Posted June 21, 2010 no. my Q was in <textarea> Quote Link to comment https://forums.phpfreaks.com/topic/205458-call-a-txt-file/#findComment-1075184 Share on other sites More sharing options...
wildteen88 Posted June 21, 2010 Share Posted June 21, 2010 The simplest way to read a file and grab its contents is with the file_get_contents function. Eg <textarea><?php echo file_get_contents('path/to/file.txt') ?></textarea> Quote Link to comment https://forums.phpfreaks.com/topic/205458-call-a-txt-file/#findComment-1075189 Share on other sites More sharing options...
icefire Posted June 21, 2010 Author Share Posted June 21, 2010 wow.. Thanx.. but still a small problem :-\ i have a menu in my site contains txt files. what i want is when a user chose a txt file from menu the path of the txt file will put automatically in code for example (path/to/file2.txt). i hope you understand what i mean sry for my "Broken English" <-- nice movie Quote Link to comment https://forums.phpfreaks.com/topic/205458-call-a-txt-file/#findComment-1075210 Share on other sites More sharing options...
kenrbnsn Posted June 21, 2010 Share Posted June 21, 2010 Can you post your code between tags? Ken Quote Link to comment https://forums.phpfreaks.com/topic/205458-call-a-txt-file/#findComment-1075211 Share on other sites More sharing options...
icefire Posted June 21, 2010 Author Share Posted June 21, 2010 include/m2.php <html> <body> <font face="verdana,arial" size="3"> <div align="center"> <form action="showcode.php" method="post" name="form123" target="iframe2"> <textarea name="msg" cols="32" rows="16"><?php echo file_get_contents('C:\xampp\htdocs\XXXX\file01.txt') ?></textarea> <input type="submit" value="Show" /> </form> </font> </div> </body> </html> menu.php <div> <ul> <li><a href="file01.txt" target="form123">Getting started </a><a href="file01.html" target="iframe2">(file01)</a></li> <li><a href="file02.txt" target="form123">Getting started </a><a href="file02.html" target="iframe2">(file02)</a></li> <li><a href="file03.txt" target="form123">Getting started </a><a href="file03.html" target="iframe2">(file03)</a></li> <li><a href="file04.txt" target="form123">Getting started </a><a href="file04.html" target="iframe2">(file04)</a></li> <li><a href="file05.txt" target="form123">Getting started </a><a href="file05.html" target="iframe2">(file05)</a></li> </ul> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> </div> Quote Link to comment https://forums.phpfreaks.com/topic/205458-call-a-txt-file/#findComment-1075219 Share on other sites More sharing options...
icefire Posted June 22, 2010 Author Share Posted June 22, 2010 Quote Link to comment https://forums.phpfreaks.com/topic/205458-call-a-txt-file/#findComment-1075480 Share on other sites More sharing options...
Ruzzas Posted June 22, 2010 Share Posted June 22, 2010 try <?php chdir("C:\xampp\htdocs\XXXX\"); echo file_get_contents('file01.txt'); ?> Quote Link to comment https://forums.phpfreaks.com/topic/205458-call-a-txt-file/#findComment-1075482 Share on other sites More sharing options...
icefire Posted June 22, 2010 Author Share Posted June 22, 2010 not work ! Quote Link to comment https://forums.phpfreaks.com/topic/205458-call-a-txt-file/#findComment-1075486 Share on other sites More sharing options...
icefire Posted June 22, 2010 Author Share Posted June 22, 2010 help me please :-\ Quote Link to comment https://forums.phpfreaks.com/topic/205458-call-a-txt-file/#findComment-1075543 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.