【问题标题】:file_put_contents(): Only 0 of 178 bytes written, possibly out of free disk space?file_put_contents():仅写入 178 个字节中的 0 个,可能是可用磁盘空间不足?
【发布时间】:2019-07-10 06:26:04
【问题描述】:

为什么会出现这个错误?

file_put_contents():仅写入 178 个字节中的 0 个,可能磁盘空间不足

 *
 * @param  string  $path
 * @return string
 */
public function hash($path)
{
    return md5_file($path);
}

/**
 * Write the contents of a file.
 *
 * @param  string  $path
 * @param  string  $contents
 * @param  bool  $lock
 * @return int
 */
public function put($path, $contents, $lock = false)
{
    return file_put_contents($path, $contents, $lock ? LOCK_EX : 0);
}

/**
 * Prepend to a file.
 *
 * @param  string  $path
 * @param  string  $data
 * @return int
 */
public function prepend($path, $data)
{
    if ($this->exists($path)) {
        return $this->put($path, $data.$this->get($path));
    }

    return $this->put($path, $data);
}

/**
 * Append to a file.

【问题讨论】:

  • 我的第一个猜测是您的服务器正在运行/已用完存储空间。 storage/logs 中有多少个日志文件(大约)?
  • 有一个日志文件 7.82 mb
  • 您的服务器上还有很多其他网站吗?
  • 总共有很多站点
  • 首先要检查网站的所有日志文件,看看是否有占用大量空间的文件。如果没有,那么您将不得不增加服务器的存储空间,迁移到更大的服务器和/或查看解决方案来托管占用相当多空间的东西(即图像,视频、用户上传等),例如 aws。

标签: php laravel


【解决方案1】:

我会尝试通过fopen,fwrite,fclose这一系列来交换函数file_put_contents,以便能够看到文件写入失败的时间点。

也许这可以为我们提供有关错误的更多详细信息。

似乎这是这个问题的重复:

Laravel 5.1: ErrorException in file_put_contents() error,possibly out of free disk space

问候

【讨论】:

    猜你喜欢
    • 2015-11-20
    • 1970-01-01
    • 2012-11-15
    • 2013-02-03
    • 2016-06-08
    • 2013-10-09
    • 2015-12-04
    • 2015-12-30
    • 1970-01-01
    相关资源
    最近更新 更多