在局域网上用PHP处理文件

在局域网上用PHP处理文件,php,file-permissions,fopen,Php,File Permissions,Fopen,您好,我正在使用fopenphp函数来维护日志。我可以在自己的计算机中写入该文件。但是如何使PHP能够在本地网络上编写文件。网络中的其他计算机通过IP访问我的计算机PHP应用程序,但在写入日志文件时未获得权限。我的代码是: function hotellog($txt) { date_default_timezone_set("Asia/Kathmandu"); $newfile = '\\localhost\gandaki/wp-content/hotel_log.json';

您好,我正在使用
fopen
php函数来维护日志。我可以在自己的计算机中写入该文件。但是如何使PHP能够在本地网络上编写文件。网络中的其他计算机通过IP访问我的计算机PHP应用程序,但在写入日志文件时未获得权限。我的代码是:

function hotellog($txt) {
   date_default_timezone_set("Asia/Kathmandu");
   $newfile = '\\localhost\gandaki/wp-content/hotel_log.json';
   if (file_exists($newfile)) {
      $myfile = fopen($newfile, "a") or die("Unable to open file!");
      $txt = date("Y-m-d h:i:s") . "\r\t\t" . $txt . "\n\n\n";
      fwrite($myfile, $txt);

      fclose($myfile);
   } else {
      $myfile = fopen($newfile, 'w') or die("Can't create file");
      $txt = date("Y-m-d h:i:s") . "\r\t\t" . $txt . "\n\n\n";
      fwrite($myfile, $txt);

      fclose($myfile);
  }
}

网络上的其他计算机会收到“权限被拒绝”的错误。

在正常情况下,PHP无法(当然,不应该)通过网络将文件写入您的计算机。您最好在本地计算机上编写日志文件,然后通过sftp或类似的方式编写从本地计算机到远程计算机的文件传输脚本。

假设您没有在这些计算机上使用
localhost
?然后正确设置权限。我已从文件系统获得读写权限,但其say权限被拒绝。共享的权限如何?对于特定用户帐户?对于每个人都有读取和执行权限。如何授予写入权限。