Qbasicnews.com

Full Version: JS/CGI and Files
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4
How can I write to files on the server using JavaScript or CGI, the way the QB INPUT and OUTPUT statements do? As in, if I wanted to use a text document to store names and messages in a guestbook?
javascript: not possible. on tricky netscape configs you can write files, but yeah, not possible.

cgi:

open (HANDLENAME, "filename");
print HANDLENAME "stuff to write";
$nextline = <INPUT>;
seek works like its qb counterpart
read works like get
tell works like seek used as a function in qb.

now, when you open it, the filename indicated the mode. there are a bunch of read write combinations (http://www.perldoc.com/perl5.8.0/pod/perlopentut.html ), but you only really need 3:

open (HANDLENAME, "filename"); #read
open (HANDLENAME, ">filename"); #write
open (HANDLENAME, ">>filename"); #append

look up the functions in the perl documentation. as perl.qb45.com is down, i'll send you to http://www.perldoc.com/

edit: i fixed a brainfart on my part.
THANK YOU!!!! Big Grin
javascript is very much possible. As far as I know you have to write it as an array, though.

Then you can link to the file:

<script src="myfile.js"></script>
How would i do that?
With javascript it is not posible to write to a file on the server. Javascript runs client-side, and not server-side [AFAIK].
Ack. I can't find Perl on "comcast.net", so I can't use CGI. Is File I/O possible with PHP?
Quote:Ack. I can't find Perl on "comcast.net", so I can't use CGI. Is File I/O possible with PHP?

Yes, php does file I/O. Very similar to perl.
hey, can you point me to a script as an example?

thanks
Pages: 1 2 3 4