2011-09-30 80 views
0

如何引用Drupal项目中的实际文件?访问独立的PHP文件

我有一个需要与php脚本交谈的Flash应用程序,但我不能只说“http:// {domain}/{filepath}/{file}”或甚至“http:// {域}}/{文件}“,假设有一些假定的路径结构。

更具体地说,该文件位于/sites/all/flash/postit.php。 Drupal如何将数据库驱动的内容绑定到实际的文件?

回答

0

如果postit.php使用其他包括,有一个结构:

FOLDER1/someincludefile.php 
someincludefile.php 
postit.php 

,并使用相对路径包括,它会引发错误的文件没有找到,所以你可以在接下来的方式包括: :

$cwd = getcwd(); // current dir. usually where index.php running. 
    $file = base_path() ."/sites/all/flash/postit.php"; // path to our script 
    $dir = dirname($file); 
    chdir($dir); // changing to file folder. 
    require_once('postit.php'); 
    // Run your code 
    .. 

    chdir($cwd); // return to own dir. 
0

你需要用PHP来引用它包括如

include "/sites/all/flash/postit.php";

如果你尝试用http://domain.com/postit.php包括它的网络服务器将处理PHP文件和所有你得到的是HTML输出。