PHP file_put_contents with absolute path?

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:

Read More
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?

Related posts

Leave a Reply

2 comments

  1. How about something like:

    file_put_contents($_SERVER['DOCUMENT_ROOT']."path/to/user/wordpress/account/".TEMPLATEPATH.'/ps_logo2.png');
    

    edit

    $_SERVER['SCRIPT_NAME'] gives the path to the script currently being processed.