Create / Edit a file on the server (Apache)

Asked

Viewed 277 times

0

With the following code I would like to create a file on the server.

<?php
    date_default_timezone_set('America/Sao_Paulo');
    $nomeArquivoLogDia = date('Ymd') . '-teste.log';

    if (file_exists($nomeArquivoLogDia)) {
        $arquivoLog = file($nomeArquivoLogDia, FILE_SKIP_EMPTY_LINES);    
    } else {
        $arquivoLog = fopen($nomeArquivoLogDia, "w+");
    }
?>

When I run php (http://localhost/teste.php) the file is not generated.

Someone knows how to do it?

  • 1

    Check right as I tested here looks ok. Was created the file.

  • Voce used wget or php? I ask because I need it with wget. Thank you

1 answer

1


Usually this type of error is permission... But to know for sure look for the error log of your host/server...

If you have access to the machine and it is *Nix, you can run cat /var/log/server_que_tu_usar/error.log

  • Good... it was only permission even. Thank you very much.

  • 1

    @mango is almost always that kkk, just take care where / folder you put permission

Browser other questions tagged

You are not signed in. Login or sign up in order to post.