tarun Posted April 1, 2007 Share Posted April 1, 2007 I Need To Get The COntents Of An External File And Put It In A Text Box Eg Say If The External File Was This <?php echo 'Simple Example' ?> Then The Page With The TextBox Looks Like This <textarea><?php echo 'Simple Example' ?></textarea> Thnx, Tarun Quote Link to comment https://forums.phpfreaks.com/topic/45130-solved-get-contents-of-external-file/ Share on other sites More sharing options...
flappy_warbucks Posted April 1, 2007 Share Posted April 1, 2007 use fopen to open the file (presuming that the file has been uploaded and on the server) $fp = fopen("text.txt","r"); if (!$fp) { die("file opening error"); } else { //what u need done to the file { Quote Link to comment https://forums.phpfreaks.com/topic/45130-solved-get-contents-of-external-file/#findComment-219082 Share on other sites More sharing options...
tarun Posted April 1, 2007 Author Share Posted April 1, 2007 It Needs To Be For An External File Hosted On A Different Server And Needs To Get The Contents Of A PHP File Quote Link to comment https://forums.phpfreaks.com/topic/45130-solved-get-contents-of-external-file/#findComment-219085 Share on other sites More sharing options...
neel_basu Posted April 1, 2007 Share Posted April 1, 2007 <?php $loc = 'location/to/file';//You can also use http://somedomein.com/page.php $file_str = file_get_contents($loc); echo $file_str; ?> I hope this will work Quote Link to comment https://forums.phpfreaks.com/topic/45130-solved-get-contents-of-external-file/#findComment-219159 Share on other sites More sharing options...
swatisonee Posted April 1, 2007 Share Posted April 1, 2007 HI Neel, Does this work if you need to get a file on your hard disk too ? I need to often access a file on my harddisk that i then need to upload to my server - but i dont want to give the user ftp access but rather do the upload thru php. Would this be possible using your solutin ? Thanks, Swati Quote Link to comment https://forums.phpfreaks.com/topic/45130-solved-get-contents-of-external-file/#findComment-219168 Share on other sites More sharing options...
neel_basu Posted April 1, 2007 Share Posted April 1, 2007 This would work on both URL or Local File System Quote Link to comment https://forums.phpfreaks.com/topic/45130-solved-get-contents-of-external-file/#findComment-219171 Share on other sites More sharing options...
swatisonee Posted April 1, 2007 Share Posted April 1, 2007 Thanks ! am going to give it a shot. May i pm you if i get into a spot ? Quote Link to comment https://forums.phpfreaks.com/topic/45130-solved-get-contents-of-external-file/#findComment-219182 Share on other sites More sharing options...
neel_basu Posted April 1, 2007 Share Posted April 1, 2007 OK But You Can add me on msn messenger i am neel_basu_2005@msn.com Quote Link to comment https://forums.phpfreaks.com/topic/45130-solved-get-contents-of-external-file/#findComment-219186 Share on other sites More sharing options...
tarun Posted April 3, 2007 Author Share Posted April 3, 2007 WoW Every1 Thnx, For Your Input Quote Link to comment https://forums.phpfreaks.com/topic/45130-solved-get-contents-of-external-file/#findComment-220710 Share on other sites More sharing options...
churdaddy Posted April 3, 2007 Share Posted April 3, 2007 Why not just include it? <?php $loc = 'location/to/file';//You can also use http://somedomain.com/page.php echo"<textarea>"; include($loc); echo"</textarea>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/45130-solved-get-contents-of-external-file/#findComment-220749 Share on other sites More sharing options...
neel_basu Posted April 4, 2007 Share Posted April 4, 2007 Actually include() is not for that purpouse Quote Link to comment https://forums.phpfreaks.com/topic/45130-solved-get-contents-of-external-file/#findComment-220949 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.