laravel - 出于安全原因,已禁用 file_put_contents()
问题描述
我将我的 laravel 上传到现有网站的子文件夹中并遇到该问题。
我在谷歌上找到了解决方案,但到处都在谈论权限被拒绝或其他问题,但如何解决呢?请指导我。
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);
}
解决方案
查看您的 php.ini 文件,并查找disable-functions
指令。如果您看到file_put_contents
那里列出,那么这就是错误的原因。
file_put_contents
从此设置中删除,然后重新启动您的 php 服务。
请参阅PHP 手册中的disable_functions参考
推荐阅读
- ios - CocoaPods 找不到 pod 的兼容版本
- c# - 为什么我以随机频率收到此“GDI+ 中发生一般错误。在 System.Drawing.Image.Save”?
- php - PHP - RethinkDB eachPOS 时间在时钟前进后延迟 1 小时
- c# - 保存按钮不会在第一次单击 Blazor Web 程序集编辑表单中触发事件
- if-statement - 列出 Haskell 中的理解和递归 if 语句
- reactjs - Switch case 不等待 React 中的 API 调用返回
- c++ - 警告:来自库的未经检查的返回值 (CHECKED_RETURN)
- database - 我可以将用户名和密码存储在文件中而不是数据库表中吗?
- javascript - 在被忽略的循环中标识“null”的 IF 语句
- c - 分配给类型“fpos_t”时由于类型不兼容导致的 fpost_t 错误