Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

mehrdad70's avatar

Image source not readable

how i can fix this error

Image source not readable

filesystem.php

        'myDriver' => [
            'driver' => 'local',
            'root' => public_path(),
            'visibility' => 'public',
        ],

    static $sizes = [300 , 600 , 900];


    public function uploadImage($values, $article)
    {
        if ($values->hasFile('images')) {
            foreach ($values->images as $image) {

                $filename = $image->getClientOriginalName();
                $dir = 'images/article';
                $path = $image->store($dir, 'myDriver');

                $article->images()->create([
                    'filename' => $filename,
                    'path' => $path
                ]);
                return self::resize(Storage::path($path), $dir, $filename);
            }
        }
    }

    public static function resize($img , $dir , $filename)
    {
        $img = Image::make($img);
        $images['original'] = $filename;
        foreach (self::$sizes as $size) {
            $images[$size] = $size . '_' . $filename;
            $img->resize($size , null , function($aspect){
                $aspect->aspectRatio();
            })->save(Storage::path($dir).'_'.$size.'.'.$filename);
        }

        return $images;
    }
0 likes
12 replies
Snapey's avatar

What problem?

by the way. you have a return statement inside your foreach loop so it will only ever execute one loop

mehrdad70's avatar

I get the following error when I want to resize the photo Image source not readable

Snapey's avatar

you are trying to make intervention image from just the path

Snapey's avatar

give it the path AND the filename ....

Snapey's avatar

The make function requires the FULL PATH, including the filename.

Not this;

$img = Image::make($img);

more like this;

$img = Image::make($img . '/' . $filename);

but you need to check your path and filename and file extension to make sure you are providing the full server path to the image

Please or to participate in this conversation.