We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOther Libraries › Server-Side File IO
Page Index Toggle Pages: 1
Server-Side File IO (Read 981 times)
Server-Side File IO
Jan 31st, 2010, 3:29am
 
I know that java's security won't allow writing to a file, but surely someone has come up with a solution to write a file server side? I want the applet to simply write and read to a basic text file. The text file doesn't necessarily have to be on the same server or location as the applet if that helps?

Has anyone ever done this?
Re: Server-Side File IO
Reply #1 - Jan 31st, 2010, 3:48am
 
You may need to write a PHP script that will write on the server.
Java->URL->PHP->TXT

It's unclear if this library is doing what you need, but it may be a good starting point: http://libraries.seltar.org/postToWeb/
Re: Server-Side File IO
Reply #2 - Feb 2nd, 2010, 5:44am
 
I guess it would be easier to just send the data to a server app running on my home PC.
Re: Server-Side File IO
Reply #3 - Feb 2nd, 2010, 7:21am
 
Well, it depends if you have PHP running or not and what type of informations you want to add. This is a quick hack for small amount of information.

<onlineWriter.php>
Code:
<?php
$data = $_GET['data'];
$myFile = "output.txt";
$fh = fopen($myFile, 'a') or die("can't open file");
fwrite($fh, $data);
fwrite("\n", $data);
fclose($fh);
?>


Then, you access your script through an URL request:
http://myServer.com/onlineWriter.php?data=SomeDataToAdd

You may use http://creativecomputing.cc/p5libs/prohtml/ to access the url.
Page Index Toggle Pages: 1