Search code examples
phplaravelfile-uploadlaravel-5enctype

getRealPath() returns false (Laravel 5.2 & Image Intervention)


When uploading images, getRealPath() always returns false:

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

Here is the result of dd($image_file);:

enter image description here

Also, when I try to use it with Image Intervention:

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

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

I am getting the following error:

NotReadableException in AbstractDecoder.php line 323: Image source not readable

Obviously because getRealPath() returns false... Someone has already asked about this problem: getRealPath returning false (Image Intervention and Laravel 5.1) ... but there is no solution.

Do you know why is this happening, how can I fix this?


Solution

  • The problem was in php.ini - incorrect upload dir.