提问者:小点点

file_put_contents()已被禁用出于安全原因


我将我的laravel上传到现有站点的子文件夹中,并遇到该问题。

[1] https://imgur.com/dSt1P7Q

我在谷歌上找到了解决方案,但到处都在谈论拒绝许可或其他事情,但如何解决它?请指引我。

file_put_contents() has been disabled for security reasons

  public function replace($path, $content)
     {
         // If the path already exists and is a symlink, get the real          vpath...
         clearstatcache(true, $path);

         $path = realpath($path) ?: $path;

         $tempPath = tempnam(dirname($path), basename($path));

         // Fix permissions of tempPath because `tempnam()` creates it with permissions set to 0600...
         chmod($tempPath, 777 - umask());

         file_put_contents($tempPath, $content);

         rename($tempPath, $path);
     }

共1个答案

匿名用户

看看你的php。ini文件,并查找禁用功能指令。如果您看到那里列出了file\u put\u contents,则这就是错误的原因。

从该设置中删除file\u put\u contents,然后重新启动php服务。

请参阅PHP手册中的禁用函数参考