PHP:更改调用脚本的环境
PHP : Change environment where the script is called
这是我的问题,我有一个php脚本,它调用了一个javascript脚本,该脚本启动了ckeditor,一个具有预定义html内容的富文本编辑器:
<?PHP
$ref = $_GET['req'];
//~ Launches ckeditor
$h = "<html><head><script src='ckeditor/ckeditor.js'></script>'n";
$h =$h."<link href='sample.css' rel='stylesheet'>'n";
$h =$h."<style>'n";
$h =$h.".cke_textarea_inline 'n";
$h =$h."{'n";
$h =$h."padding: 10px;'n";
$h =$h."height: 500px;'n";
$h =$h."overflow: auto;'n";
$h =$h."border: 1px solid gray;'n";
$h =$h."-webkit-appearance: textfield;'n";
$h =$h."}'n";
$h =$h."</style></head><body>'n";
$h = $h."<div style='position:absolute; left:50px; top:120px; width:1200px; height:600px;'>'n" ;
$h =$h."<form action='posteddata.php' method='post'>'n";
$h =$h."<textarea name='article-body' style='height:600px'>'n";
//~ Add a submit button which is irrelevant to my problem
$f = "</textarea><p><input type='submit' value='Submit'></p></form>'n";
$f = $f."<script>CKEDITOR.inline( 'article-body' );</script>'n";
$f = $f."</body></html>'n";
chdir($ref);
if(file_exists("System Specification.html"))
{
$file = fopen("System Specification.html", "r");
print $h;
while (!feof($file))
{
print fgets($file,4096);
}
print $f;
}
else
{
echo "Cannot open file";
}
?>
问题是,在我的html文件中,我调用一些具有相对路径的图像,如
<img src='images/2/1.gif' />
图像文件夹在我的$ref文件夹中。图像不收费,因为脚本没有在好的目录中启动。我想强迫剧本知道他改变了自己的道路,这样他就可以在正确的地方获取图像。我尝试了chdir,但没有成功。如果我把我的images文件夹放在与php脚本相同的级别上,它就可以工作,但我不能这样做(这个脚本的目的是在一个大型数据库中,在这个数据库中,树状场景无法更改,副本会太重)。有人能解决这个问题吗?我很难解释这一点,所以如果还不太清楚,你可以问一些问题以获得更多信息。
//~ Launches ckeditor
$h = "<html><head><script src='ckeditor/ckeditor.js'></script>'n";
$h.= "<link href='sample.css' rel='stylesheet'>'n";
$h.= "<style>'n";
$h.= ".cke_textarea_inline 'n";
$h.= "{'n";
$h.= "padding: 10px;'n";
$h.= "height: 500px;'n";
$h.= "overflow: auto;'n";
$h.= "border: 1px solid gray;'n";
$h.= "-webkit-appearance: textfield;'n";
$h.= "}'n";
$h.= "</style></head><body>'n";
$h.= "<div style='position:absolute; left:50px; top:120px; width:1200px; height:600px;'>'n" ;
$h.= "<form action='posteddata.php' method='post'>'n";
$h.= "<textarea name='article-body' style='height:600px'>'n";
//~ Add a submit button which is irrelevant to my problem
$f = "</textarea><p><input type='submit' value='Submit'></p></form>'n";
$f = $f."<script>CKEDITOR.inline( 'article-body' );</script>'n";
$f = $f."</body></html>'n";
相关文章:
- 当包含另一个asp文件时,是否也包含所有引用的样式和脚本页面
- 借助asp.net验证或java脚本对多个文本进行验证
- chrome扩展:尽管运行了at:documentidle,js脚本还是过早启动
- Java脚本时间添加
- 不显示带有本地json文件数据的谷歌地图脚本
- JQuery添加元素需要在我的js之前再次添加JQuery脚本
- 从远程脚本获取用户IP
- 如何在谷歌应用程序脚本环境中获取谷歌搜索输出
- 如何从批处理文件调用一个带有2个参数的java脚本函数,并将结果返回到环境变量
- PHP:更改调用脚本的环境
- WP管理员试图在htpasswd保护的环境中异步加载脚本
- 重新加载 Chrome 扩展程序内容脚本执行环境
- 在 sharepoint 环境中使用脚本调用 lists.asmx Web 服务
- Can Kentico's脚本和css缩小被禁用用于开发环境
- 如何在多个环境(终端和浏览器)中运行JavaScript测试脚本
- 如何在可能已经有引导脚本的环境中加载引导脚本
- 环境变量打字脚本
- 什么是正确的方式来写我的脚本'src'本地开发环境的Url
- 实现在游戏脚本环境中使用自定义对象模型的jQuery
- 使用Windows脚本复制子进程环境