Page 1 of 1

Simple text file creation fails....

Posted: Sun Apr 17, 2005 4:59 pm
by folken7182
Hello guys and girls... I have a problem trying to create a simple text file... it doesn't want to be created... It just return that can't write or can't be created..

I have tried with the example of fwrite from http://www.php.net and even that example fails...

Code: Select all

<?php
$nombre_archivo = 'prueba.txt';
$contenido = "Agregar esto al archivo\n";


if (is_writable($nombre_archivo)) {

	if (!$gestor = fopen("$nombre_archivo", 'a')) {
		echo "No se puede abrir el archivo ($nombre_archivo)";
		exit;
	}


	if (fwrite($gestor, $contenido) === FALSE) {
		echo "No se puede escribir al archivo ($nombre_archivo)";
		exit;
	}

	echo "&Eacute;xito, se escribi&oacute; ($contenido) al archivo ($nombre_archivo)";

	fclose($gestor);

} 
else {
	echo "No se puede escribir sobre el archivo $nombre_archivo";
}
?>

Posted: Sun Apr 17, 2005 5:06 pm
by hongco
have you chmod the folder to 777 where the file should be saved at?

Posted: Sun Apr 17, 2005 5:11 pm
by folken7182
I am working in Windows, Using xampp I don't know if I need permissions