perfect
Joined: 8th Jul 2009
Posts: 1424
Re: PHP Grabbing a files contents from a link?
Not quiet understanding what you want.
If your talking about making text into a link TO a file your going to want <a href="url">link text</a>.
If your looking to load the contents of a text file into an editor on a webpage (you mentioned grabbing), you could look at file_get_contents();. And obviously to save, file_put_contents();
Or you could use fopen();, fread();, and fclose(); which will do the same thing essentially. fopen, fread, and fclose
is extremely similar to how you would access a text file in C++ using IO.stream library.
8 years, 18 weeks ago
|
Re: PHP Grabbing a files contents from a link?
<a href = "pagetoopen.php?linkname.txt" target = "_blank"> File Name </a>
pagetoopen.php is the web page with the editing form linkname.txt is ofcourse the file name you want to open with the link.
<?php
$link = isset($_GET['linkname.txt']) ? $_GET['linkname.txt'] : ''; $text = "";
if(!empty($link)) $text = file_get_contents($link); echo '<textarea >'.$text.'</textarea>';
?>
$link checks to see if linkname.txt is part of the url pagetoopen.php?linkname.txt .$text should be the contents of the linkname.txt if the file exists or you will have an empty textarea ect ect.
8 years, 17 weeks ago
| |