Re: Problem with file reading
| From: | Fahad Pervaiz | Date: | Fri, 05 Jan 2007 16:08:11 +0000 |
| Subject: | Re: Problem with file reading | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-246607@lists.php.net to get a copy of this message | ||
===ORIGINAL===
Hi,
I'm a beginner and i'm still learning PHP and I got a problem:
$file = "http://localhost/test_folder/test1.txt";<http://localhost/test_folder/test1.txt>//I
have also
tried "test_folder/test1.txt" and "text1.txt"
$fh = fopen($file, "r") or die("Could not open file!");
$data = fread($fh, filesize($file)) or die ("Could not read file!");
fclose($fh);
echo $data;
The file exist, I'm using apache server on my PC for practicing and the
file is located in the servers root folder on the subfolder "test_folder".
Help would be greatly appreaciated
Thanks in advance!
===END ORIGINAL===
Try using the complete path in $file... you can get the complete path by
using
$_SERVER['DOCUMENT_ROOT']
Also be sure that path given in $file variable is relatvie to location
of php file that is executing
--
Regards
Fahad Pervaiz
www.ecommerce-xperts.com
(Shopping Cart, Web Design, SEO)