Ver Mensaje Individual
  #6 (permalink)  
Antiguo 08/07/2005, 13:59
Avatar de Spiritmonger
Spiritmonger
 
Fecha de Ingreso: febrero-2004
Ubicación: Ciudad de México
Mensajes: 44
Antigüedad: 20 años, 2 meses
Puntos: 0
Y para los que estén interesados, este es el código que encontré (está en inglés)

En el flash quedaria asi :

var fileContents = "This is the string we are writing to the file.";

loadVarsText = new loadVars();
loadVarsText.onLoad = function(success) {
if (success) {
if (this.wroteFile == true) {
trace("Success! Write to file complete.");
} else {
trace("Error, write to file failed!.");
}
} else {
trace("Error, loadVars failed!");
}
};
loadVarsText.load("writeFile.php?&stuffToWrite="+f ileContents);

Y el PHP, quedaría así

<?php

$filename ="myFile.txt";
$writeError = false;
$fileStream;

if (!$fileStream = fopen($filename,'a')) {
$writeError = true;
} else {
if (!fputs($fileStream, $stuffToWrite)) {
$writeError = true;
} else {
fclose($fileStream);
}
}

print "&wroteFile=".$writeError;
?>


The FLASH actionscript is contacting the PHP script and supplying the
stuffToWrite. The PHP script will open the file path specified in $filename
of the PHP script and use fopen() to open the file for writing. Refer to
this link --> http://www.php.net/manual/en/function.fopen.php to see how you
actually want to use fopen() in your PHP script. At the moment it is set to
write to the end of the file; fopen($filename,'a').The
PHP script then returns wroteFile back to the FLASH actionscript to tell it
if it failed or not. Be sure that the PHP script is somewhere that "other"
or "nobody" has permissions to create/edit the text file.
__________________
"Dar cualquier cosa que sea menos que lo mejor de uno mismo es sacrificar el don que han recibido"