Solved

Can Javascript write to a file??

Posted on 2006-10-21
9
206 Views
Last Modified: 2008-01-16
I would like to have javascript write to a flat file that's on the server. Is this possible? What are the commands if it is? I'm working with a particular server that can only run html pages and doesn't have any programming languages installed like ASP or PHP.
0
Comment
Question by:bemara57
9 Comments
 
LVL 49

Accepted Solution

by:
Ryan Chong earned 125 total points
ID: 17781028
>>I would like to have javascript write to a flat file that's on the server. Is this possible?
NO for javascript, but yes for Java Applet/ActiveX Control or Server Side Scripting Languages.
0
 
LVL 41

Assisted Solution

by:HonorGod
HonorGod earned 125 total points
ID: 17781677
Not in client side, yes for server side Javascript
0
 
LVL 12

Expert Comment

by:jessegivy
ID: 17782788
what is it you're trying to accomplish?  perhaps a file isn't best solution?  if client side solution is required you could use cookies, but I'm sure you've got other options.

Cheers,

Jesse
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 11

Assisted Solution

by:cup
cup earned 125 total points
ID: 17782970
If you are working in a windows environment, yes.  On the client side, it depends on whether Javascript is enabled and whether your browser allows it.

var fso, src, srcstr
fso = new ActiveXObject ("Scripting.FileSystemObject");
dst = fso.OpenTextFile ("the file", 2);  // 1 = read, 2 = write, 8 = append
dst.Write ("some text");
dst.close ();
0
 

Author Comment

by:bemara57
ID: 17784144
but this will write onto a file that resides on the client side correct? What I'm trying to accomplish is having a flat file that keeps count of all the hits on specific pages. The only hurdle to this is that the server i'm working with cannot have a server side scripting language installed nor MySQL installed. Its a bare naked server that has to stay that way for corporate reasons. So all I have to work with is html and javascript. Its using apache on unix if that helps.. but I just can't install anything more than that.
0
 
LVL 49

Expert Comment

by:Ryan Chong
ID: 17784159
If your server is so limited that doesn't allow you to use some way to write info into it, we're sorry that we may also can't help you here..

The alternative way may be is to use FTP transfer method... you may FTP your latest info into your server, and when your user read those info from some where else, hopefully what he/she saw is the latest info, but this will be the last resource (backup plan) I can suggest to you.

>>What I'm trying to accomplish is having a flat file that keeps count of all the hits on specific pages.
Depends on what Web Server you're using, you may already have a Log generated from each hit count. Try check this with web administrator, to see whether the Web Server Log is available by default or not?
0
 
LVL 12

Assisted Solution

by:str_kani
str_kani earned 125 total points
ID: 17786906
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
Avoid defining the variables in the global scope; trying to define them in a local function scope. Because:   • Look-up is performed every time a variable is accessed.   • Variables are resolved backwards from most specific to least specific scope…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now