Kevin Griffiths Kevin Griffiths - 10 months ago 60
PHP Question

Why can't I see my .txt file from this php script

I'm using this script to see the content of a .text file -


$file = fopen("Gin_List_Website.txt","r");

echo("ERROR:cant open file .. :(");
echo("opened the file .. :)");

$buff = fread ($file,filesize("Gin_List_Website.txt"));
print $buff;
echo $buff;

But all I see is this line

opened the file .. :)

What am I doing wrong?

Answer Source

First you need to change if(!file) with if(!$file).

Here is more simple code example:

    $file = fopen("Gin_list_Website.txt", "r") or die("Unable to open file!");
    echo fread($file,filesize("Gin_list_Website.txt"));
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download