RE : [PHP] Still problem with file reading

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



You cite a windows path to your txt file.I warn you that you need to write c:\ as c:/, because the \ is the escapechar into a string

so, to point to C:\Program Files\XAMPP\xampp\htdocs\test_folder\test1.txt from php you need:
$file_path = "C:\\Program Files\\XAMPP\\xampp\\htdocs\\test_folder\\test1.txt";
(note I use " and not '
or
$file_path = "C:/Program Files/XAMPP/xampp/htdocs/test_folder/test1.txt";

and then you should be able to
$data = file_get_contents($file_path);



Vincent Dupont
Ausy Belgium



-------- Message d'origine--------
De: Richard Lynch [mailto:ceo@xxxxxxxxx]
Date: ven. 1/5/2007 22:43
À: Delta Storm
Cc: php-general@xxxxxxxxxxxxx
Objet : Re:  Still problem with file reading
 
On Fri, January 5, 2007 12:45 pm, Delta Storm wrote:
> I wrote a while back saying of my problem...
>
> I tried to read a file I tried in a couple of ways and i posted a
> question on this newsgroup and a couple of people helped me (btw,
> thank
> you for help) and they suggested a few other ways I tried all possible
> ways and i could read a file it says:
>
> Failed to open stream! No such file or directory exists
>
> while im 100% sure the file exists
>
> path of the file: C:\Program
> Files\XAMPP\xampp\htdocs\test_folder\test1.txt
>
> htdocs is apache's root directory I tried setting the file there
> C:\Program Files\XAMPP\xampp\htdocs
>
> but still the same I have tried the URL approach the above aproach the
> plain "test1.txt" aproach as to relative to the DOCUMENT_ROOT i have
> tried everything but still it doesn't work
>
> I tried to use echo is_readable and file_exists and it returned
> negative, that the file does not exists but i say again the file does
> exist I didn't spelled it wrong I have checked a hundred times but
> always the same answer!
>
> PLEASE HELP, I'm learning PHP by a book and I have a whole section
> about
> file reading,writing... And I dont want to skip any part of the book!
> :)
>
> If you need more info, I'll be happy to answer any question.

Two suggestions:
1. Show us your exact code.  Either copy/paste it into email, or
provide a URL to the source code by copying (or better yet symlinking)
to a .phps file (the 's' is not a typo)

2. Sometimes PHP will say the file is "not there" when what it REALLY
means is "I do not have permission to read that file or directory"
If PHP can't read the directory the file lives in, it can't even SEE
the file to find out if it's there or not.

Unfortunately, the permissions model in Windows changes with every
release, so what this boils down to is poking around in endless
windows in "Properties" on all the directories and files until you
make things work.

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux