21489 Posts in 5783 Topics by 2621 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 629 Views |
-
Fetch Data from Text File

27 May 2010 at 5:48pm
hello everyone,
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));
fclose($fh);
return $theData;but it s showing error "no such file or directory" ... Is it the right way ?? or please tell me how to do it...
-
Re: Fetch Data from Text File

27 May 2010 at 6:29pm
get it working... just need to give the full path of file
-
Re: Fetch Data from Text 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.
| 629 Views | ||
|
Page:
1
|
Go to Top |


