Forum Moderators: coopster

Message Too Old, No Replies

Problem with fopen and file location, simple problem?

         

kenfused

5:34 am on Feb 20, 2006 (gmt 0)

10+ Year Member



Hello,

I have a PHP script that uses

fopen("$filename");

I want to use this script in multiple directories on my site, however, it seems like I have to have a copy of "$filename" in every directory to get it to work.

I have tried fopen("/filename")
fopen("http://mysite.com/filename")

and none of these seem to work, I always get a file does not exist error, until I drop the "filename" file into the directory where the script is being run.

Any ideas how I can make this work so I don't have to have dozens of "filename" all over my site?
THANKS

ramoneguru

6:09 am on Feb 20, 2006 (gmt 0)

10+ Year Member



Hmmmm, I'd hate to recommend you to hardcode the pathname in the fopen statement instead of using a variable, but try it out and see what happens. Stick the file outside all the directories and then try

$handle = fopen("<file location here>", 'r');// or write, w/e
I'd say check the location of the file and make sure you didn't leave out a directory when specifying where it is....
--Nick