How to Write Text File to Web Server

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Pete Martinez
    New Member
    • Sep 2010
    • 2

    How to Write Text File to Web Server

    Greetings, I need a simple method using ActiveXobject in javascript to write a text file from the local drive to my webserver. I found a method on a previous thread that copies a file from the webserver to the local drive that works but I need to reverse this. The code I found previously on the posting from "drink.the.cool aid" is as follows.
    _______________ _______________ __
    Create a text file called c:\GetWebPage.j s:

    Code:
    var fso = new ActiveXObject('Scripting.FileSystemObject');
    var args = WScript.Arguments;
    var url = args(0);
    var fileName = args(1);
    var xmlhttp=new ActiveXObject("microsoft.xmlhttp");
    xmlhttp.open("GET", url, false);
    xmlhttp.send();
    var data=xmlhttp.responsetext;
    var file = fso.CreateTextFile(fileName, 2);
    file.writeLine(data);
    file.close();
    >From a command line type:
    cscript /nologo c:\GetWebPage.j s http://www.YOUR_URL_HERE.com c:
    \YOUR_OUTPUT_FI LE_HERE.txt
    _______________ _______________ _______

    Is there a way to reverse this code to copy the file from the local to the webserver instead?
    Last edited by gits; Sep 18 '10, 10:10 AM. Reason: added code tags
  • gits
    Recognized Expert Moderator Expert
    • May 2007
    • 5390

    #2
    what exactly do you want to do? is the file already at the client or is it created uring a session and you just want to save the data at the server?

    Comment

    • Pete Martinez
      New Member
      • Sep 2010
      • 2

      #3
      The text file is created on the javascript client-side and I would like to copy it to the webserver using a similar method to the sample that I posted. I have tested that script and it works with some modification but I need to reverse the copy method from the local file to the web server wwwroot or a subfolder instead.

      Comment

      • gits
        Recognized Expert Moderator Expert
        • May 2007
        • 5390

        #4
        in case the textfile is created clientside you just need to send the data with a request to the server and write it to a file ... you might use a simple AJAX-call for that purpose ... or is that your question?

        Comment

        Working...