【发布时间】:2016-07-30 16:11:23
【问题描述】:
我正在尝试使用 Laravel 文件系统获取外部文件,但我不断收到 File does not exist at path 异常
这是我的代码
File::get('http://lorempixel.com/272/172');
被调用的 Laravel 函数
public function get($path, $lock = false)
{
if ($this->isFile($path)) {
return $lock ? $this->sharedGet($path) : file_get_contents($path);
}
throw new FileNotFoundException("File does not exist at path {$path}");
}
我已经在我的服务器上测试了file_get_contents('http://lorempixel.com/272/172'),效果很好。
如果在我得到的 if 语句中执行dd($path),这很奇怪
"/home/vagrant/Code/test/storage/framework/sessions/fdb554540ba30a38464950b36908fa20e0ee94cc" 已返回
如果我在 if 语句之外执行 dd($path),我会得到 http://lorempixel.com/272/172 返回
我很困惑
【问题讨论】:
标签: php laravel file-get-contents