Good Day to all,
Ahm, does anyone here know how can i make a function that get the filepath of a specific file?
I want to create a function like this:
- getFilePath('A_file_with_an_unknown_path.inc');
then the function will return the path of the file with an unknown path/directory.
Is this possible? If not, can anyone tell me how can I be able to include a file with an unknown filepath/directory?
- require_once('???/???/???/A_file_with_an_unknown_path.inc');
Please help.
Thank you in advance.
How to find the path of a specific file?
Moderator: General Moderators
- superdezign
- DevNet Master
- Posts: 4135
- Joined: Sat Jan 20, 2007 11:06 pm
Re: How to find the path of a specific file?
The only way to do this is to know the path and directory.
I have no idea why you would want to do this, or how you would go about finding a random file in a file system, but if you know the location of the file in relativity to the file that is including it, using dirname() in combination with the __FILE__ constant can give you the current directory.
I have no idea why you would want to do this, or how you would go about finding a random file in a file system, but if you know the location of the file in relativity to the file that is including it, using dirname() in combination with the __FILE__ constant can give you the current directory.
Re: How to find the path of a specific file?
or you could write an entire program for searching all of the dir and files on your server. Sounds like alot of work to me.
Re: How to find the path of a specific file?
Oh, i see, thank you for the reply.
Re: How to find the path of a specific file?
You could use getcwd() to get your current directory, then tack on the part of the filename you know, then run that through realpath().
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.