SEO Scripts
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   SEO Chat ForumsOtherSEO Scripts

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread SEO Chat Forums Sponsor:
  #1  
Old January 29th, 2004, 02:49 PM
JRM JRM is offline
Contributing User
SEO Chat Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 108 JRM User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 1 m 21 sec
Reputation Power: 6
Question JavaScript Write file on server

How can I write to a file on the server using JavaScript? If not possible can I run a Server-side script from client-side Javascript, PHP for example? Example: On a onclick event I want to send a function some text of what the user clicked, and save the text into a file or into a database, on My web server.

Thank you,

JRM

Reply With Quote
  #2  
Old January 29th, 2004, 03:34 PM
iTISTIC iTISTIC is offline
Registered User
SEO Chat Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: New Port Richey, FL
Posts: 2 iTISTIC User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to iTISTIC Send a message via AIM to iTISTIC Send a message via MSN to iTISTIC Send a message via Yahoo to iTISTIC
You could do this by putting an <img> tag somewhere on the page, and changing it's source to a server-side script file (PHP, CGI, ASP, etc.) and pass along the text you wish to store. This server-side script file could then write to the file or database and output a blank image. I'd also have the javascript pass some random string in the src also to make sure the browser requests a new image and doesn't think it is cached.

Shawn
iTISTIC.com

Reply With Quote
  #3  
Old January 29th, 2004, 11:22 PM
relaxzoolander's Avatar
relaxzoolander relaxzoolander is offline
web designer
SEO Chat Frequenter (2500 - 2999 posts)
 
Join Date: Aug 2003
Location: designing a web site in columbus ohio
Posts: 2,993 relaxzoolander User rank is Private First Class (20 - 50 Reputation Level)relaxzoolander User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 3 h 49 m 3 sec
Reputation Power: 8
Post

javascript will not do this.
you can use cgi or asp.
do you have a preference?
pick one and i will send you the code.
[not sure about that img tag idea.]

Reply With Quote
  #4  
Old January 30th, 2004, 08:49 AM
JRM JRM is offline
Contributing User
SEO Chat Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 108 JRM User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 1 m 21 sec
Reputation Power: 6
CGI would probably work best. I'm not on a M$ box. Thank you Relaxzoolander

The image thing confused me a little too. I want to track a click on a specific link, not all just a couple.

JRM

Last edited by JRM : January 30th, 2004 at 08:56 AM. Reason: Adding comment

Reply With Quote
  #5  
Old June 22nd, 2005, 11:03 AM
mylesdolan mylesdolan is offline
Registered User
SEO Chat Newbie (0 - 499 posts)
 
Join Date: Jun 2005
Posts: 1 mylesdolan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 m 55 sec
Reputation Power: 0
how to write Hello World to a file on server using javascript or CGI?

Did you manage to find the solution to this problem? if so can you post it on site or send it to me .
Thanks in advance
MD

Reply With Quote
  #6  
Old August 22nd, 2005, 10:17 AM
SEO_Jonty SEO_Jonty is offline
Registered User
SEO Chat Newbie (0 - 499 posts)
 
Join Date: May 2005
Location: Johannesburg, South Africa
Posts: 9 SEO_Jonty User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 3 m 41 sec
Reputation Power: 0
Hi JRM, you can actually use JavaScript to write or read from a file. The only problem is that its Client Side Code which can disabled by the clients browser, rendering you code obsolete. Anyway the imbedded object is a Microsoft active x object called FileSystemObject.

I have include the code here to help you out. Give me a shout if you need more answers.

Code:
function WriteToFile()
{
  try 
  {
    var fso, s;
    fso = new ActiveXObject("Scripting.FileSystemObject");
    s = fso.CreateTextFile("C:\\test.txt", true);
    s.writeline("This is a test");
    s.Close();
  } 
  catch(err)
  {
   var strErr = 'Error:';
   strErr += '\nNumber:' + err.number;
   strErr += '\nDescription:' + err.description;
   document.write(strErr);
  }
}


Make sure you set your file permissions wherever your txt file is to full write permissions, and set your security custom level in IE to initialize active x objects marked as safe.

Last edited by SEO_Jonty : August 22nd, 2005 at 10:55 AM.

Reply With Quote
  #7  
Old October 19th, 2005, 02:07 PM
steven steven is offline
Registered User
SEO Chat Newbie (0 - 499 posts)
 
Join Date: Oct 2005
Posts: 1 steven User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 m 31 sec
Reputation Power: 0
write on server

He cool it works, but
how should i write on the server,
what should be a correct serverroot,
i'm no javascript user that's wy i'm asking.

please let me know if possible.

steve

Reply With Quote
  #8  
Old October 20th, 2005, 01:44 AM
Catacaustic Catacaustic is offline
Contributing User
SEO Chat Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 130 Catacaustic User rank is Private First Class (20 - 50 Reputation Level)Catacaustic User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 3 Days 16 h 56 m 8 sec
Reputation Power: 4
Quote:
Originally Posted by SEO_Jonty
Make sure you set your file permissions wherever your txt file is to full write permissions, and set your security custom level in IE to initialize active x objects marked as safe.
This idea is good in theory, but isn't quite as good in practice. What you're proposing will write to the local machine's C drive using that code, which isn't at all usefull for writing to a server as was asked in the original question.

Of course, you can always set up fle permissions to allow writing from a remote server, but this would also allow ANYONE to write ANYTHING to your server that they wanted to , and that's an open invitation for hackers to come and hijack your box.

The CGI methods that have been suggested here are the best in my opinion. I'd use PHP because that's what I know, and it's easy to have a function set up that'll write information to a file quickly and easily.

Reply With Quote
  #9  
Old October 20th, 2005, 04:08 AM
SEO_Jonty SEO_Jonty is offline
Registered User
SEO Chat Newbie (0 - 499 posts)
 
Join Date: May 2005
Location: Johannesburg, South Africa
Posts: 9 SEO_Jonty User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 3 m 41 sec
Reputation Power: 0
Quote:
Originally Posted by Catacaustic
This idea is good in theory, but isn't quite as good in practice.

The CGI methods that have been suggested here are the best in my opinion.


I agree, eventhough i supplied the code, it is only an example and using client side code to do this isnt practical for a variety of reasons, one of them being that it is client-side and the user might disable javascript on his browser rendering your code useless.

What i do suggest you do, is using a filesystemobject in ASP or if you choose a similar object in PHP.

Reply With Quote
  #10  
Old May 9th, 2008, 04:22 AM
tony5745 tony5745 is offline
Registered User
SEO Chat Newbie (0 - 499 posts)
 
Join Date: May 2008
Posts: 1 tony5745 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 m 50 sec
Reputation Power: 0
I want to get ASP sample about wrtie file in server

Quote:
Originally Posted by relaxzoolander
javascript will not do this.
you can use cgi or asp.
do you have a preference?
pick one and i will send you the code.
[not sure about that img tag idea.]


I want to get ASP sample about wrtie file in server

Reply With Quote
Reply

Viewing: SEO Chat ForumsOtherSEO Scripts > JavaScript Write file on server


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT