Need basic Cgi help to save a text file


#1

So I volunteered to design a dynamic flash website without any real skills to further the ‘dynamic’ side of things. The flash I’ve got all figured out, but I need help building a basic cgi (I assume… better way?) page to save a text file to the server. IE, a textbox that the news can be typed in to with a button that submits it and saves it to whatever.txt to be accessed by the flash file.
I found a prebuilt one, but I couldn’t for the life of me make it work, even with the knowledge of dreamhost’s screwy cgi permissions. I’d like to just set this in a htaccess-ed directory so that the admin can simply use his password and update it.

Any suggestions?

Cheers!


#2

For what you’re asking you’ll have to build the actionscript functionality into the flash movie itself. The flash movie will use the loadVariables functionality to access the static text document on the server, which can be updated via ftp with whatever frequency it changes.

http://www.flashmagazine.com/478.htm
http://www.oman3d.com/tutorials/flash/loading_external_text_bc/

You will only have to lean on server side scripting if ftp isn’t a viable option for you. Are you rendering strictly text language, or will it include formatting like html code? You can save text input from a form submission by using something similar to the following on a PHP action page.

[code]<?php
$submittedtext = $_POST[“submittedtext”];
$filename = “/home/user/textdocs/textfile.txt”;

if (!$handle = fopen($filename, ‘w’)) {
print “Cannot open file ($filename)”;
exit;
}

if (!fwrite($handle, $submittedtext)) {
print “Cannot write to file ($filename)”;
exit;
}

fclose($handle);
?>
[/code]http://us3.php.net/fopen


#3

Ah, simple php. If only I was better at searching help files…

Cheers!