Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Dec 2003
    Posts
    132
    Thanks
    0
    Thanked 0 Times in 0 Posts

    javascript read/write .txt files on the server

    is it possible to read, or write .txt files to the server?

    it would also be useful to know how one would parse the txt file with js.

    I have seen vbscript write a .js file, but i need a txt file, and i would prefer
    to use javascript.

    thanks a hundred billion
    UNDER CONSTRUCTION

  • #2
    fci
    fci is offline
    Senior Coder
    Join Date
    Aug 2004
    Location
    Twin Cities
    Posts
    1,345
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Not with JavaScript. Server-side language such as PHP would do what you want.
    JavaScript is client-side only... so the only actions which can be performed by JavaScript are limited to a person's browser..
    in php it could be done like this:
    Code:
    <?php
    $file = file_get_contents('path/to/file.txt');
    //perform any parsing routines... $parsed_file
    $f = fopen('path/to/file.txt', 'w');
    fwrite($f, $parsed_file);
    fclose($f);
    ?>


  •  

    Posting Permissions

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