按用户按钮生成文件不起作用

Pushing user button to generate a file does not work

下面的代码应该生成一个文件。

问题:为什么没有创建文件?

index2.php

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>
<body>

</html>

<form method="post" action="run.php">
        <input
          id="button_1"
          type="submit"
          name="button_1"
          value="Send"
        >
</form>

</body>
</html>

run.php

# -----------------------
# Button event listeners.
# -----------------------

if (isset($_POST["button_1"])) {
  ConstructDocument();
}

// DOMDocument

function ConstructDocument()
{

// Root
$xml = new DomDocument('1.0', 'UTF-8');
$xml->formatOutput = true;

// Elememet
$xbrli = $xml->createElement('xbrli:xbrl');
$xml->appendChild($xbrli);

// Print & Save.
echo $xml->saveXML();
$xml->save("auto_produced_xbrl.xhtml");

}

您需要将写入的文件夹设置为用户www-data:www-data。要隔离给定的权限,建议您创建一个单独的文件夹并仅提供对该文件夹的权限。上面提到的user/group代表任何通过浏览器访问网络服务器的用户。