I use WordPress and PHP and the function file_put_contents(). WordPress file structure can look different depending on the user.
I need to call it like this:
file_put_contents(TEMPLATEPATH . '/ps_logo2.png');
or the same thing like this:
file_put_contents('C:wampwwwdomainmodehallen.se/wp-content/uploads/images/ps_logo2.png');
The case above is the absolute path on localhost (that’s why it’s C:). I need the path or some other way to make sure the file is put in the right place.
How is this done?
How about something like:
edit
$_SERVER['SCRIPT_NAME']
gives the path to the script currently being processed.realpath()
will tell you if it is a valid path in the filesystem. To test if the path is actually in a given ‘sandbox’ path, see the answers to this question I asked here recently.