How would you reference an actual file in a Drupal project?
I have a flash app that needs to talk to a php script, but I can't just say "http://{domain}/{filepath}/{file}" or even "http://{domain}/{file}" assuming there was some assumed pathing struc开发者_如何学Pythonture.
To be more specific, the file lives in /sites/all/flash/postit.php. How would Drupal tie it's database driven content to an actual file?
If you postit.php use additional includes, that have next structure:
FOLDER1/someincludefile.php
someincludefile.php
postit.php
and use relative path for including, it will raise error that files doesn't found, so you can include in next manner:
$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.
You'll need to reference it with a PHP include such as
include "/sites/all/flash/postit.php";
If you try to include it with http://domain.com/postit.php the webserver will process the PHP file and all you'll get is the HTML output.
精彩评论