fopen cannot locate file??

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
iceb
Forum Newbie
Posts: 17
Joined: Mon Oct 28, 2002 6:18 am

fopen cannot locate file??

Post 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;


?>
litebearer
Forum Contributor
Posts: 194
Joined: Sat Mar 27, 2004 5:54 am

Post 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...
iceb
Forum Newbie
Posts: 17
Joined: Mon Oct 28, 2002 6:18 am

path

Post by iceb »

ok but what path should I use ?

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