Click to See Complete Forum and Search --> : viewing txt file data


mitchell
07-21-2007, 05:13 PM
is there anyone or a place that will give me information about the following:

1. can i view txt file data on another page.
2. is there anyway to edit the text file using a javascript codes e.g. text box

if you know how to do any of the above especially No1 it would be gratefully,thanks

chestertb
07-21-2007, 09:09 PM
what do you mean by "view txt file data on another page"?

do you mean you want to view text on one page that's displayed on otehr page, or do you mean you want to read a text file, and display that file on a different page to the one you're viewing?

mitchell
07-22-2007, 09:09 AM
i want to read a text file, and display that file on a different page to the one im viewing is exactly what i want, please could you help me with that.

mitchell
07-22-2007, 01:29 PM
it ok, i found this:

<?php
readfile('somefile.txt');
?>

can someone help me with telling me
some code that will make it editable on a page and be able to save it

hastx
07-22-2007, 10:28 PM
use file_get_contents(), or fopen()/fread(), to read the contents of the file and echo those contents to a textarea. after submission use file_put_contents() to place the edited data back into the file.

as far as viewing the content on another page, I would use javascript to open a popup displaying the content:


<a href="javascript:void(open('view_file.php?filename=whateverfile.txt','','top=50,left=50'))">view whateverfile.txt</a>


on the view_file.php page:

<?
$filename = $_GET['filename'];
$output = file_get_contents($filename);
echo"<pre>$output</pre>";
?>


the semantics of the code are missing from this post...but it should give you an idea.