Page 1 of 1

fopen cannot locate file??

Posted: Sun Apr 04, 2004 12:21 pm
by iceb
Hi

I cannot get this to work.

How come ?

LINK: http://m.iceb.dk/readu.php

ERROR: Warning: filesize(): Stat failed for Resource id #2 (errno=2 - No such file or directory) in /var/www/epoxy/web2/icebdk/docs/readu.php on line 4

CODE:

<?php

$fp = fopen("readme.txt", "r");
$data = fread($fp, filesize($fp));

echo $data;


?>

Posted: Sun Apr 04, 2004 1:20 pm
by litebearer
Reading the contents
$filename = 'c:\file.txt';
$fp = fopen($filename, "r");

$contents = fread($fp, filesize($filename));
fclose($fp);
Display the contents
print $contents;

writing to the file
$filename = 'c:\file.txt';
$fp = fopen($filename, "a");
$string = "\nline5";
$write = fputs($fp, $string);
fclose($fp);

hope this helps.

Lite...

path

Posted: Sun Apr 04, 2004 1:29 pm
by iceb
ok but what path should I use ?

I mean the file is on a webhotel so how can I find the path ???