Results 1 to 3 of 3

Thread: writing to text file

Threaded View

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Sep 2005
    Posts
    1,364

    writing to text file

    i uploaded a text file called 'logs.txt' and write.php to a www folder on a server (i got a subdomain)

    so the links to these are like, E.G:.
    www.site-here.com/logs.txt
    www.site-here.com/write.php


    then why doesnt something like this work:

    www.site-here.com/write.php?txt=Hello

    and it should write the word 'Hello' to logs.txt

    Heres write.php..

    PHP Code:
    <?php
    $filename 
    'logs.txt';
    $somecontent $_GET['txt'] . "\n"

    if (
    is_writable($filename)) {

       if (!
    $handle fopen($filename'a')) {
             echo 
    "Cannot open file ($filename)";
             exit;
       }

       if (
    fwrite($handle$somecontent) === FALSE) {
           echo 
    "Cannot write to file ($filename)";
           exit;
       }
       
       echo 
    "Success, wrote ($somecontent) to file ($filename)";
       
       
    fclose($handle);

    } else {
       echo 
    "The file $filename is not writable";
    }
    ?>
    any help guys?

    i just keep getting: Cannot write to file logs.txt
    Last edited by Pouncer; Sep 19th, 2005 at 03:00 PM.

Posting Permissions

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



Click Here to Expand Forum to Full Width