1
votes

I need to require a file inside of a drupal node, for example:

<?php 
require('/help/sites/all/themes/help12/brightcove/bc-mapi.php');

//Do Stuff Here

?>

I get the error:

warning: require(/help/sites/all/themes/help_infusion12/brightcove/bc-mapi.php): failed to open stream: No such file or directory in C:\dev\srv\Apache2.2\htdocs\help\includes\common.inc(1696) : eval()'d code on line 2.

The file is there, I've tested it on a php script outside of drupal. Not sure whats getting messed up.

Thanks for the help.

3
suggest that you use the drupal way using drupal_get_path() with example given by Clive - optimusprime619

3 Answers

2
votes

The 'Drupal' way:

$path = drupal_get_path('theme', 'help12');
require ($path . '/brightcove/bc-mapi.php');
0
votes

Try

require('../../help/sites/all/themes/help12/brightcove/bc-mapi.php');

or

require('../sites/all/themes/help12/brightcove/bc-mapi.php');
0
votes

It looks like you are developing on your PC. Since you have an absolute path, beginning with slash, Apache will treat that as beginning at SERVER_ROOT.

Take a look in your httd.conf and you will see something like

# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "c:/xampp/htdocs"

In which case, Apace would look for

c:/xampp/htdocs/help/sites/all/themes/help12/brightcove/bc-mapi.php

It is probably better to use a relative path.

Please note that this is not a Drupal problem (btw, stackexchange has a good Drupal site).

Good luck!