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

时间:2019-07-18 12:38:08

标签: laravel

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

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

我在Google上找到了解决方案,但是到处都在谈论拒绝权限或其他什么问题,但是如何解决呢?请引导我。

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 个答案:

答案 0 :(得分:0)

查看您的php.ini文件,并寻找disable-functions指令。如果您看到file_put_contents列在其中,那就是错误的原因。

从此设置中删除file_put_contents,然后重新启动php服务。

请参见PHP手册中的disable_functions参考