PHP fopen fwrite=禁止403
我正试图通过另一个php文件编辑index.php文件。在我的本地测试服务器上,我使用xampp,它运行得很好,但在我的主机上,它给了我403个错误,我想我的代码有问题 这是我使用的代码PHP fopen fwrite=禁止403,php,Php,我正试图通过另一个php文件编辑index.php文件。在我的本地测试服务器上,我使用xampp,它运行得很好,但在我的主机上,它给了我403个错误,我想我的代码有问题 这是我使用的代码 <?php if($_POST){ $open = fopen("../index.php","w+"); $text = $_POST['update']; fwrite($open,
<?php
if($_POST){
$open = fopen("../index.php","w+");
$text = $_POST['update'];
fwrite($open, $text);
fclose($open);
echo "File updated.<br />";
}else{
$file = file("../index.php");
echo "<p>Welcome</p><br />";
echo "<form action=\"".$_SERVER['PHP_SELF']."\" method=\"post\">";
echo "<textarea Name=\"update\" cols=\"150\" rows=\"40\">";
foreach($file as $text) {
echo $text;
}
echo "</textarea>";
echo "<br/>";
echo "<input name=\"Submit\" type=\"submit\" value=\"Update\" />\n
</form>";
}
?>
和save.php
<?php
$fs = fopen( $_POST["file"], "a+" ) or die("error when opening the file");
fwrite($fs, $_POST["contents"]);
fclose();
?>
也许PHP在服务器端与其他用户一起运行。您可以通过运行来检查这一点。有些用户可能有其他用户没有的访问权限。我运行whoami,得到了我的用户lubjor,但我不确定这对我有什么帮助,以及在我的代码中在哪里使用它。你能给我一个提示吗?