【发布时间】:2018-10-17 13:11:54
【问题描述】:
我正在使用 CentOS7。我的 index.html、action.php 和 file.txt 都在同一个文件夹中。我已经将 chown apache:apache 设置为整个 /var/www/html 树。该文件确实打开了,但我无法向其写入任何内容。这是我的第一个 PHP 代码,所以如果我是愚蠢的,请告诉我。 var_dump($_POST);工作正常。
<?php
$name = $_POST['fname'];
$fp = fopen("file.txt","w") or die("Can not open file");
fwrite("file.txt",$name) or die ("can not write to file");
fclose($fp);
?>
【问题讨论】: