Still problem with file reading

This is a discussion on Still problem with file reading within the PHP General forums, part of the PHP Programming Forums category; Hi, I wrote a while back saying of my problem... I tried to read a file I tried in a ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-05-2007
Delta Storm
 
Posts: n/a
Default Still problem with file reading

Hi,

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.

THANK YOU in advance!
Reply With Quote
  #2 (permalink)  
Old 01-05-2007
Al
 
Posts: n/a
Default Re: Still problem with file reading

You probably have a owner and/or permissions problem. Try setting the dir to 777.

Read fopen() in the php manual. There are dozens of user notes on the subject.

Delta Storm wrote:
> Hi,
>
> 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.
>
> THANK YOU in advance!

Reply With Quote
  #3 (permalink)  
Old 01-05-2007
David Giragosian
 
Posts: n/a
Default Re: [PHP] Re: Still problem with file reading

>
> Why don't you start by running file_exists() on another file in the same
> directory:



if (file_exists("./findMe.php"))
echo "It's here";

then, directory by directory, move towards where you want the real file to
be read. If a move fails, check permissions as already suggested ( and
capitalization, also, if on a *nix system ). Once you can accomplish this,
fopen() should work just fine.

David

Reply With Quote
  #4 (permalink)  
Old 01-05-2007
Richard Lynch
 
Posts: n/a
Default Re: [PHP] 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?
Reply With Quote
  #5 (permalink)  
Old 01-05-2007
Vincent DUPONT
 
Posts: n/a
Default RE : [PHP] Still problem with file reading

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.tx t";
(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@l-i-e.com]
Date: ven. 1/5/2007 22:43
À: Delta Storm
Cc: php-general@lists.php.net
Objet : Re: [php] 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
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 03:48 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0