469,337 Members | 5,957 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,337 developers. It's quick & easy.

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.coolaid" is as follows.
________________________________
Create a text file called c:\GetWebPage.js:

Expand|Select|Wrap|Line Numbers
  1. var fso = new ActiveXObject('Scripting.FileSystemObject');
  2. var args = WScript.Arguments;
  3. var url = args(0);
  4. var fileName = args(1);
  5. var xmlhttp=new ActiveXObject("microsoft.xmlhttp");
  6. xmlhttp.open("GET", url, false);
  7. xmlhttp.send();
  8. var data=xmlhttp.responsetext;
  9. var file = fso.CreateTextFile(fileName, 2);
  10. file.writeLine(data);
  11. file.close();
  12.  
>From a command line type:
cscript /nologo c:\GetWebPage.js http://www.YOUR_URL_HERE.com c:
\YOUR_OUTPUT_FILE_HERE.txt
_____________________________________

Is there a way to reverse this code to copy the file from the local to the webserver instead?
Sep 17 '10 #1
3 2938
gits
5,390 Expert Mod 4TB
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?
Sep 21 '10 #2
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.
Sep 21 '10 #3
gits
5,390 Expert Mod 4TB
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?
Sep 21 '10 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by Google Mike | last post: by
1 post views Thread by Gurk | last post: by
6 posts views Thread by Kevin Ingram | last post: by
2 posts views Thread by Tom Youngquist | last post: by
1 post views Thread by WebSim via .NET 247 | last post: by
2 posts views Thread by sympatico | last post: by
1 post views Thread by lokeshrajoria | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.