Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > What is up with fopen??? FOpen and local directories

Reply
Thread Tools

What is up with fopen??? FOpen and local directories

 
 
Nonee
Guest
Posts: n/a
 
      10-25-2005
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
 
Reply With Quote
 
 
 
 
Nonee
Guest
Posts: n/a
 
      10-25-2005
Not that you guys probably care, but yes, I am an idiot. I knew it
would be simple. The second form that reads and writes the guests.txt
file posts to a file in the upper directory, not the local because
the post file RESIDES in the upper directory and not the local. I
created a dynamic hidden form field with the current directory that
holds the index.php so then the post file can use the hidden field to
create the txt file in the index.php directory.... Been a long day.

Yes folks, I win the darwin award. hehe....

-Josh

On Tue, 25 Oct 2005 19:47:07 GMT, Nonee <(E-Mail Removed)> wrote:

>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


 
Reply With Quote
 
 
 
 
Neredbojias
Guest
Posts: n/a
 
      10-25-2005
With neither quill nor qualm, Nonee quothed:

> Not that you guys probably care, but yes, I am an idiot. I knew it
> would be simple. The second form that reads and writes the guests.txt
> file posts to a file in the upper directory, not the local because
> the post file RESIDES in the upper directory and not the local. I
> created a dynamic hidden form field with the current directory that
> holds the index.php so then the post file can use the hidden field to
> create the txt file in the index.php directory.... Been a long day.
>
> Yes folks, I win the darwin award. hehe....
>
> -Josh


Hey, anyone can make a simple mistake, but I've rarely heard it so
comprehensively described.

--
Neredbojias
Contrary to popular belief, it is believable.
 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
fopen - file and directories ?? fdm C++ 15 10-13-2009 07:28 AM
local file access? fread? fopen? weinjared@gmail.com Javascript 18 12-19-2008 12:04 AM
Virtual Directories and Physical directories Paul M Fin MCAD 4 06-27-2008 07:50 PM
fopen() with full path affecting subsequent fopen calls Michel Rouzic C Programming 4 04-28-2008 04:48 PM
Extracting Directories and Sub Directories and Counting Ron Smith Perl Misc 5 11-02-2004 11:23 PM



Advertisments