Results 1 to 4 of 4

Thread: Overwriting a txt file using php and ftp.

  1. #1
    Join Date
    Apr 2009
    Posts
    10
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Overwriting a txt file using php and ftp.

    Hi, I'm a noob at php and other coding stuff so i need a little help.

    What I am trying to achieve is: a textarea with a submit button, and when you click the submit button it edits/overwrites a file in my server.

    If you need more info, please contact me, thanks,
    Joseph

  2. #2
    Join Date
    Mar 2008
    Posts
    218
    Thanks
    7
    Thanked 19 Times in 19 Posts

    Default

    Quote Originally Posted by josephtaylor1995 View Post
    Hi, I'm a noob at php and other coding stuff so i need a little help.

    What I am trying to achieve is: a textarea with a submit button, and when you click the submit button it edits/overwrites a file in my server.

    If you need more info, please contact me, thanks,
    Joseph
    maybe this is useful
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
    <style type="text/css">
    textarea {
    font-size:11px;
    font-family:"Courier New", Courier, mono;
    	}
    </style>
    </head>
    <body>
    <?php
    
    if(isset($_POST['submit'])) {
    $content = $_POST['contents'];
    $file = fopen("script.txt", "w");
    fwrite($file, $content);
    fclose($file);
    }
    ?>
    
    <h1>Alter TEXT File</h1>
    <form name="edit" method="post">
    <textarea name="contents" cols="80" rows="23">
             <?php
                    $file = "script.txt";
                    $open = fopen($file, "r");
                    $size = filesize($file);
                    $count = fread($open, $size);
    
                    echo($count);
            ?>
    </textarea><br />
    	<input type="submit" name="submit" value="Submit">
    </form>
    </body>
    </html>

  3. The Following User Says Thank You to tfit For This Useful Post:

    josephtaylor1995 (04-05-2009)

  4. #3
    Join Date
    Apr 2009
    Posts
    10
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    thanks ive been looking all day for a script like this, did you make it or did you get it off a side? what site did you get it off if you did? thanks again

  5. #4
    Join Date
    Mar 2008
    Posts
    218
    Thanks
    7
    Thanked 19 Times in 19 Posts

    Default

    I am afraid I'll have to disappoint you. It's sample code of php.net.
    OT: I did some extreme DIY the last few months and got really annoyed with open/unclosed threads. So, if your question is answered please push it to resolved. Thanks in advance

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •