PDA

View Full Version : Flash data to .txt with PHP, GET ok POST fail


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

CyanBlue
01-05-2007, 03:00 PM
Are you testing that within the Flash IDE or within the web browser???
FYI, Flash IDE only emulates GET not POST...

gazpachu
01-05-2007, 03:04 PM
Im testing it in the browser. BTW, maybe the error is not in the GET or POST but in the data to copy to the file. When I use GET, I am only sending a word.... (thru the explorer URL bar) but when I use the POST, Im sending 90kb of data... I don't know, it shouldn't fail anyway

CyanBlue
01-05-2007, 03:06 PM
I agree that it should not fail if you are just swapping GET and POST... Hm...

gazpachu
01-07-2007, 09:02 PM
I've fixed it! The file writeToFile.php had was not well written :S

Thank you anyway. Clossing topic...