You are here: What is up with fopen??? FOpen and local directories « HTML « IT news, forums, messages
What is up with fopen??? FOpen and local directories

Posted by Nonee on 10/25/05 22:47

Ok, could anyone tell me why exactly guests.txt is opening in a higher
directory instead of the local directory?

$filename = "guests.txt";
$handle = fopen($filename, "r");

It opens the file, not in the current calling php file's directory,
but the directory above it... What is going on?!? So it creates the
file in c:\ instead of c:\phpfiles\ where the index.php file is
located (just for example). Now, what is happening is you fill out a
form, use the data from the form to create a directory and output an
index.php file in that directory. Then, from the index.php file
located in the newly created directory runs the above lines. So why
is the index.php file from the new directory opening the guests.txt
file in the upper directory where the form php file is stored instead
of the new index.php file in the deeper directory? Did I lose
everyone like I have myself? I have never been that good at
.../names.txt etc and file locations and I can really use some help
please... Do I need like a "../guests.txt" or ./guests.txt or
something? I have a feeling it is something VERY stupid. Please be
gentle... heh.

Thanks,

Josh

Also, the form.php creates the index.php file from two other files,
top and bottom.php (reads and outputs both to index.php). I put in my
own stuff in between top and bottom and sandwich them all together in
index.php. Index.php outputs correctly but will not open guests.txt
in the local newdirectory but in the root. HEEELP! : )

// I want this...
- Root
- form.php
- top.php
- bottom.php
- NewDirectory
- index.php <-- file that tries to read guests.txt
- guests.txt

// ...but I get this
- Root
- form.php
- top.php
- bottom.php
- guests.txt
- NewDirectory
index.php

 

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

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