Php crea un archivo si no existe
Intento crear archivos y escribir los contenidos dinámicamente. A continuación se muestra mi código.
$sites = realpath(dirname(__FILE__)).'/';
$newfile = $sites.$filnme_epub.".js";
if (file_exists($newfile)) {
$fh = fopen($newfile, 'a');
fwrite($fh, 'd');
} else {
echo "sfaf";
$fh = fopen($newfile, 'wb');
fwrite($fh, 'd');
}
fclose($fh);
chmod($newfile, 0777);
// echo (is_writable($filnme_epub.".js")) ? 'writable' : 'not writable';
echo (is_readable($filnme_epub.".js")) ? 'readable' : 'not readable';
die;
Sin embargo, no crea los archivos.
Por favor comparte tus respuestas y ayuda. ¡Gracias!