tags:

views:

32

answers:

4

My code is inside a plugin's init function and I'm trying to file_get_contents() on a file inside my plugin folder..

I'm using...

file_get_contents(ABSPATH.'/wp-content/plugins/myplugin/myfile.html');

Not sure why can't I just use...

file_get_contents('myfile.html');
A: 

myfile or myfile.html?

henchman
myfile.html (I edited the question to correct)
Scott B
A: 

Try this:

file_get_contents('./myfile.html');
Sarfraz
I thought that, but its still giving me issues. I believe its because the file is being loaded into plugins.php from another directory, which becomes the current relative path.
Scott B
A: 

you can file function also, to read the specific file.

Refer following link

link text

pavun_cool
Thanks, my ? is not so much about the method, but rather about the apparent unique relationship of the path when code is being executed inside a plugin's init function in wordpress.
Scott B
A: 

Is php file where you call file_get_contents called directly or required from another script? Path to files calculated from file, which run directly. For example: in index.php my be required 'plugins/i/plagin78.php If in plugin78.php you called file_get_contents('myfile.html') then myfile.html should be placed in same category as index.php, not plugin78.php

Andrew