Laravel 5.4 fopen (): File name cannot be empty

I want to upload an image in laravel 5.4. Here is the code:

if ($request->hasFile('image') && $request->image->isValid()) {
        $image = $request->image;

        $image_name = bcrypt($image->getClientOriginalName());

        Storage::disk('public')->putFileAs('images', $image, $image_name . '.' . $image->getClientOriginalExtension());

        $article->image($image_name);
    }

in FilesystemAdapter.php (line 146)

I checked FileSystemAdapter.php and saw that the problem is in this line:

$stream = fopen($file->getRealPath(), 'r+');

When I var dump the $ file variable, it returns the correct information, but when I var_dump($file->getRealPath();say bool(false), and I can’t load the image

+4
source share
1 answer

We had this problem with Internet Information Services (IIS) for Windows® Server. And all that was needed was a permission for C: \ Windows \ temp, because it was set as upload_tmp_dir in php.ini for php7.

+5
source

Source: https://habr.com/ru/post/1683456/


All Articles