simple php script to add line/file to text file
Hello, i have a txt file that i serve up on my apache server (http://192.168.0.1/info.txt) running on my debain box. I am very new to php and dont know a lot at all. I want users to go to a web site if they want to add a single line ("www.google") or have an option to add a text file if they have multiple entries. If they upload a text file i want it to append (cat add.txt >> info.txt) to info.txt.
Please let me know your thoughts on this |
I figured it out here is what i did:
<?php $fn = "file.txt"; $file = fopen($fn, "a+"); $size = filesize($fn); $space.= "\n"; if($_POST['addition']) fwrite($file, $_POST['addition']); $text = fread($file, $size); fwrite ($file, $space); fclose($file); ?> <form action="<?=$PHP_SELF?>" method="post"> <input type="text" name="addition"/><br/> <input type="submit"/> </form> file is the text file that you will add to |
All times are GMT -5. The time now is 02:38 PM. |