2

上传图片时,getRealPath()总是返回false

$image_file = $request->file('image_file');
$image_file->getRealPath(); // ---> FALSE

这是结果dd($image_file);

在此处输入图像描述

此外,当我尝试将它与图像干预一起使用时:

        $image_file = $request->file('image_file');

        Image::make($image_file->getRealPath())->.....

我收到以下错误:

AbstractDecoder.php 第 323 行中的 NotReadableException:图像源不可读

显然是因为getRealPath()返回false...有人已经问过这个问题:getRealPath return false (Image Intervention and Laravel 5.1) ...但是没有解决方案。

你知道为什么会发生这种情况,我该如何解决这个问题?

4

2 回答 2

2

问题出在php.ini - 上传目录不正确。

于 2017-01-27T20:19:17.630 回答
0

我遇到了同样的问题getRealPath()。当我返回 false 时dd()。尝试$request->getPathname()改用。

于 2020-03-25T18:48:14.433 回答