You are here: Re: Does 'fopen' work only within the same directory? « PHP Programming Language « IT news, forums, messages
Re: Does 'fopen' work only within the same directory?

Posted by Gordon Burditt on 09/13/05 18:30

Relative paths are interpreted with respect to the current
directory.

>I'm trying to read a file with PHP:

Is safe mode on? Does the *user running PHP* (it's a fairly safe
bet this is *NOT* 'frank', but more likely 'www', 'apache', 'nobody86'
or 'daemon') have permission to open the file (that means permissions
on /, /home, /home/frank, /home/frank/otherdir, and
/home/frank/otherdir/foo.txt have to be appropriate).

>--------------------
>$fileToRead = "foo.txt"; //Option-1
>#$fileToRead = "/home/frank/otherdir/foo.txt"; //Option-2
>
>$dataFile = fopen($fileToRead, "r") ;
>-------------------
>
>Option-1 works but Option-2 doesn't, but 'foo.txt' is COMPULSORY within
>another
>directory.

What error message do you get when it fails? (Turn on error_reporting
if it's not already).

Gordon L. Burditt

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация