EOSERV Forum > Game Development > PHP Grabbing a files contents from a link?
Page: << 1 >>
PHP Grabbing a files contents from a link?
Author Message
Post #202145 PHP Grabbing a files contents from a link?

Ok so I've got a bunch of files listed on a page along with an text display/input. I'm able to manually type the file name and get the file to load in the text display so I can edit and save it. But I was wondering how I'd go about making the file names into links and when clicked they get loaded in the text display/editor.

I'm sorry if I've explained this badly If it's not enough I'll try explain aha

---
https://Havenshost.net/ - Cheap Windows VPS
2 years, 10 weeks ago
Post #202146 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.

2 years, 10 weeks ago
Post #202147 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.
2 years, 10 weeks ago
Page: << 1 >>

EOSERV Forum > Game Development > PHP Grabbing a files contents from a link?