【发布时间】:2016-08-29 09:14:40
【问题描述】:
我在学校服务器上的私人文件夹中写入文件时遇到问题。我听说问题是我的权利。还是代码?我相信文件夹位置是正确的。我收到一些错误:
1 $testfile = "SchoolServer/Test.txt";
2
3 if (!file_exists($testfile))
4 {
5 $fileoperation = "a";
6 $test = preg_replace( '/\h+/', ' ', $test);
7 $file = fopen ($testfile, $fileoperation);
8 fwrite ($file, $week . "\r\n" . $test . "\r\n" . "\r\n");
9 fclose ($file);
10 }
警告:file_exists():open_basedir 限制生效。文件(Test.txt)不在允许的路径内:第 3 行 D:\Register-test.php 中的 (D:\SitesTemp)
警告:fopen():open_basedir 限制生效。文件(Test.txt)不在允许的路径内:第 7 行的 D:\Register-test.php 中的 (D:\SitesTemp)
警告:fopen(Test.txt):打开流失败:第 7 行的 D:\Register-test.php 中不允许操作
警告:fwrite() 期望参数 1 是资源,布尔值在第 8 行的 D:\Register-test.php 中给出
警告:fclose() 期望参数 1 是资源,布尔值在 D:\Register-test.php 第 9 行给出
谢谢!
【问题讨论】:
-
你在 $testfile = "SchoolServer/Test.txt" 中使用了什么完整路径;它是完整的路径吗?你试过在你的 php 文件中使用 print_r($_SERVER) 吗?
-
这是写在 if (!file_exists($testfile)) 中的,目的是检查文件是否存在。如果没有,它会写入它。如果它已经存在,它不会覆盖,而是将内容添加到已经存在的文件中
标签: php