怎么样解决多层路径问题
目录结构如下:根目录:test
|-test
|-test|-index.php
|-test|-version|-index.html
|-test|-editor|-login.html
|-test|-editor|-login.php
|-test|-editor|-admin|-index.php
|-test|-editor|-admin|-show.php
|-test|-editor|-admin|-rewrite.php
功能:通过show.php,实现对version下面的index.html文件进行读写操作,也就是编辑。
文件读取和写入的路径应该怎么写?
我现在的写法是:
show.php中:
$list=file_get_contents($_SERVER[ 'DOCUMENT_ROOT']."/version/index.html");
<form method='post' action="rewrite.php" >
<input type="text" name="test" value="<?php echo $list; ?>">
<input type="submit" name="submit" id="submit" value="提交">
</form>
rewrite.php中:
file_put_contents($_SERVER[ 'DOCUMENT_ROOT']."/version/index.html",$test);
如果我使用127.0.0.1进行域名配置,将test根目录包含进去,在本地也就是windows下运行没有错误,但是上传到服务器之后,文件可以读取到,但是写入操作会出现问题报出以下错误:
Warning: file_put_contents(/var/www/wwwroot/www.test.com/test/version/index.html) [function.file-put-contents]: failed to open stream: Permission denied in/var/www/wwwroot/www.test.com/test/editor/admin/rewrite.php on line 8
我想这个应该就是路径的问题,但是解决不了,请大家帮帮忙!
哦,还有这个在本地访问如果使用localhost/test/或者本地IP/test/访问也会报出路径错误,希望大家能帮忙解决下,顺便说说以后遇到这样的路径问题应该如何解决,谢谢!
我也遇到这样的问题不会解决 我不是ぁ天使 发表于 2012-5-6 07:55 static/image/common/back.gif
我也遇到这样的问题不会解决
问题解决了,linux下的所有文件及文件夹的访问权限为可读,但是做写入操作需要可写权限,配置下linux的文件访问权限就行了。
页:
[1]