22851 Posts in 9874 Topics by 2804 members
|Go to End|
27 May 2010 at 5:48pm
i'm trying following code to show data from text file to user....
$myFile = "testing.txt";
$fh = fopen($myFile, 'r');
$theData = fread($fh, filesize($myFile));
but it s showing error "no such file or directory" ... Is it the right way ?? or please tell me how to do it...
27 May 2010 at 6:29pm
get it working... just need to give the full path of file
27 May 2010 at 6:30pm Last edited: 27 May 2010 6:31pm
Make sure you have the path correct. In SilverStripe the base path for PHP scripts is /sapphire/ (because the 'root' is sapphire/main.php) If I remember correctly so what every path you give to fopen has to be relative to the sapphire/ dir.
[edit heh you bet me my a couple minutes]
Hard coding the full path is risky as if you ever move the site it will break.
|Go to Top|