PDA

View Full Version : Easily Update Dynamic Text File


DANSSWARE
07-01-2005, 05:17 AM
I have a flash site powered by dynamic text files. These call formatting, etc. I need to create some sort of online form that can post additions to the file in the proper format of the text file... How can I go about this?

Boskic.com
07-01-2005, 04:51 PM
You are reading variables (text) from text file, and you want to write to same file at the end of file?

DANSSWARE
07-02-2005, 02:44 AM
Yea.. Flash draw the variable from the text file and I want to append to the top of the text file, within the one variable.

Thanks!

Boskic.com
07-02-2005, 02:02 PM
Not knowing the construction of your txt file with dynamic data, presuming that text file is containing multiple variables, in wich case first variable is Var1=Something, and the others are &VarZ=Else, try this PHP function.<?php
//path to the file
$path = "Variables.txt";
//chmod($path, 0777); - You may need this to write on disk!

//request new variables
$append = $_REQUEST['Data'];
$appenddata = "$append\r\n&";

//Just a precaution in case of empty Data string
if (!empty($append)) {

//reading
$r = fopen($path,"r");
$read = fread($r, filesize($path));
fclose ($r);

//writing
$w = fopen($path,"w");
fwrite($w, "$appenddata$read");
fclose ($w);
}
?> Feeding with data http://www.yoursite.com/This.php?Data=VarXYZ=SomeData
Also there is an example in attachment.