• Hello,

    I want to program a simple plugin that reads the content of a .txt file.

    I tried file_get_contents() .
    If I call a URL, then it works without problems.

    <?php
    $page = file_get_contents('https://www.example.com/');
    echo $page;
    ?>

    However, when I try to read a text file (that I upload in the same folder) it doesn’t work. Unfortunately, I can’t get the values.

    <?php
    $file = file_get_contents('./test.txt');
    echo $file;
    ?>

    I’ve also tried different paths and also specified the exact path, etc. But it doesn’t help.

    The .txt file has read and write permissions.

    I’ve read that some hosts have disabled the file_get_contents() function for security reasons (probably in php.ini?).
    Unfortunately, my hoster says that he cannot activate anything (since it is not dedicated hosting).

    What solutions/alternatives are there? Somehow it must work to read a simple .txt file.

    Thanks in advance.

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Read .txt file content’ is closed to new replies.