Ver Mensaje Individual
  #1 (permalink)  
Antiguo 03/06/2005, 13:21
Number Seven
 
Fecha de Ingreso: diciembre-2003
Mensajes: 41
Antigüedad: 20 años, 4 meses
Puntos: 0
Pregunta Problemas con archivos (fopen, fwrite)

Gente salvadora de este foro, a ver si e puede ayudar con este problrma. Primero lesmuestro los archivos, luegoles esxplico el problema:

Archivo: grabar.php
-------------------
<?
function grabar_linea($file, $txt)
{
fwrite($file, $txt) or die ("unable to open file ($file)");
}
?>
-------------------
Archivo: bruno_xml.php
-------------------
<?php
include ("grabar.php");

$myXml = fopen("bruno.xml","w+") or die('<script>alert(\'No se puede crear el nuevo archivo.\')</script>');

function ExportDirectoryXML($base, $indent)
{
if ($dir = @opendir($base))
{
while ($file = readdir($dir))
{
if ($file{0} != ".")
{
if (is_dir($base . "/" . $file))
{
$content="$indent&lt;directory name=\"$file\" type=\"directory\"&gt;\n";
grabar_linea($myXml, $content);
ExportDirectoryXML($base . "/" . $file, $indent."\t");
$content="$indent&lt;/directory&gt;\n";
grabar_linea($myXml, $content);
}
else $content="$indent&lt;file name=\"$file\" type=\"actionscript\" /&gt;\n";
grabar_linea($myXml, $content);
}
}
closedir($dir);
}
}
$directory = realpath("downloads/fotos");
ExportDirectoryXML($directory, "");
fclose($myXml);
?>
--------------------------------------------------------------------------

Al ejecutar este ultimo php, el explorador me tira: "Warning: fwrite(): supplied argument is not a valid stream resource in /www/docs/misitio.com.ar/public_html/data/grabar.php on line 4"

Siempre y cuando ejecute la función grabar_linea(); dentro de la otra función, ya que sino el archivo erscribe correctamente... podría ser que la función estuviesebuscando a la otra como local en vez de global???

Soy un beginner con PHP, quien pueda ayudarme... ante todo, muchas gracias.