gazpachu
01-05-2007, 02:21 PM
Why does this script works with $_GET['datos'] thru the explorer with WriteToFile.php?datos=whatever
<?php
$open = fopen($_SERVER['DOCUMENT_ROOT']."/data/inmuebles.txt", 'w'); //opens or creates (if it doesn't already exist) our text file for writing (not reading) and places the pointer at the end.
$datosNuevos = $_POST['datos']; //with $_GET['datos'] works thru the explorer with WriteToFile.php?datos=whatever
$write = fwrite($open, $datosNuevos); //writes to our specified file our string
//sends a response back to flash stating success or failure
if($write) { //since fwrite returns a value of true or false, $write will be either true or false
echo "&verify=success&"; //prints to screen &verify=success which flash will read and store as myVars.verify
} else { // simple if statement
echo "&verify=fail&"; //prints to screen &verify=fail which flash will read and store as myVars.verify
}
//closes the PHP file.
?>
and it doesn't work with $_POST['datos'] thru Flash with the following code:
myVars.datos = txtDatos.text;
myVars.sendAndLoad("writeToFile.php", myVars, "POST");
txtDatos.text contains a 143 lines and 639 cols String...
The succesful txt file should look like this: www.proyecto2025.es/data/inmuebles2.txt
<?php
$open = fopen($_SERVER['DOCUMENT_ROOT']."/data/inmuebles.txt", 'w'); //opens or creates (if it doesn't already exist) our text file for writing (not reading) and places the pointer at the end.
$datosNuevos = $_POST['datos']; //with $_GET['datos'] works thru the explorer with WriteToFile.php?datos=whatever
$write = fwrite($open, $datosNuevos); //writes to our specified file our string
//sends a response back to flash stating success or failure
if($write) { //since fwrite returns a value of true or false, $write will be either true or false
echo "&verify=success&"; //prints to screen &verify=success which flash will read and store as myVars.verify
} else { // simple if statement
echo "&verify=fail&"; //prints to screen &verify=fail which flash will read and store as myVars.verify
}
//closes the PHP file.
?>
and it doesn't work with $_POST['datos'] thru Flash with the following code:
myVars.datos = txtDatos.text;
myVars.sendAndLoad("writeToFile.php", myVars, "POST");
txtDatos.text contains a 143 lines and 639 cols String...
The succesful txt file should look like this: www.proyecto2025.es/data/inmuebles2.txt