Thanks - seems to be working now - may have been a cache problem.
However I have attempted to now write more than one variable to the text
file and it only appears to be writing the first one.
Here is my PHP code
<?php
$filename = $_POST['filename'];
$text1_Font = $_POST['text1_Font'];
$text1_Size = $_POST['text1_Size'];
if (!$handle = fopen($filename, 'w')) {
echo "&message=Cannot open file&";
exit;
}
if (fwrite($handle, $text1_Font,$text1_Size) === FALSE) {
echo "&message=Cannot write to file&";
exit;
}
fclose($handle);
echo "&message=$text1_Font&$text1_Size&";
?>
Any ideas why the second variable is not getting written?
This is my action script
var vSender = new LoadVars();
var vReceiver = new LoadVars();
vSender.text1_Font = text1_Font;
vSender.text1_Size = text1_Size;
vSender.action = "write";
vSender.filename = "order2.txt";
vReceiver.onLoad = function(success) {
trace ("onLoad function");
if (success) {
trace("text writen to the text file:\n" +
this.message);
content_txt.text = this.message;
} else {
trace("error");
content_txt.text = "error";
}
};
vSender.sendAndLoad("http://www.mediakitchen.co.uk/clients/davehann/testpost
.php", vReceiver, "POST");
Thanks
Paul
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Serge
Sent: 25 August 2006 13:34
To: Flashcoders mailing list
Subject: Re: [Flashcoders] OT: Create a text file on server using
PHPwithvariables from Flash
This is working for me.
Serge
<?php
$filename = 'test.txt';
$somecontent = "Add this to the file\n";
$handle = fopen($filename, 'w')
// Write $somecontent to our opened file.
if (fwrite($handle, $somecontent) === FALSE) {
echo "Cannot write to file ($filename)";
exit;
}
echo "Success, wrote ($somecontent) to file ($filename)";
fclose($handle);
?>
----- Original Message -----
From: "Paul Steven" <[EMAIL PROTECTED]>
To: "'Flashcoders mailing list'" <[email protected]>
Sent: Friday, August 25, 2006 4:15 AM
Subject: [Flashcoders] OT: Create a text file on server using PHP
withvariables from Flash
> Anyone have a working example of a PHP script to create a text file using
> PHP?
>
> I am trying to get the following to work but it is not creating the text
> file on my server. I have set the permissions of the folder to 777 which
> should in theory allow a file to be created.
>
> Thanks
>
> Paul
>
> <?php
> // the name of the text file
> $filename = 'test3.txt';
>
> // hard code the variable from flash
> $somecontent = "Add this to the file\n";
>
> // If the file doesn't exist, attempt to create it
> // and open it for writing
> // anything already writen will be replaced
> if (!$handle = fopen($filename, 'w')) {
> echo "&message=Cannot open file&";
> exit;
> }
>
> // Write $somecontent to the opened file.
> if (fwrite($handle, $somecontent) === FALSE) {
> echo "&message=Cannot write to file&";
> exit;
> }
> // close the file
> fclose($handle);
>
> // send the variable to flash
> echo "&message=$somecontent&";
>
> ?>
>
> _______________________________________________
> [email protected]
> To change your subscription options or search the archive:
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
> Brought to you by Fig Leaf Software
> Premier Authorized Adobe Consulting and Training
> http://www.figleaf.com
> http://training.figleaf.com
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com