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

grgbikash05's avatar

Image source not readable (Laravel Intervention)

use Intervention\Image\ImageManagerStatic as Image;

$teammember = new TeamMember;

    $mem_name = $request->input('name');
    $position = $request->input('position');
    $skills = $request->input('skills');
    $joined = Carbon::now();
    if ($request->hasFile('image')) {
        $image = $request->file('image');
        $name = time().'.'.$image->getClientOriginalName();
        $name = Image::make($name)->resize(10, 10);
        $destinationPath = public_path('/images/members');
        $image->move($destinationPath, $name);
        $image = $name;
    }

    TeamMember::insert([
        'name' => $mem_name,
        'position' => $position,
        'skills' => $skills,
        'joined' => $joined,
        'image' => $image,
    ]);

Error:: Image source not readable problem.. What is wrong on this code...

0 likes
1 reply
Snapey's avatar
    $image = $request->file('image');
    $name = time().'.'.$image->getClientOriginalName();
    $name = Image::make($name)->resize(10, 10);

You are trying to make an image from a string. $name contains timestamp plus the filename - not the image sent from the browser.

Try this;

    if ($request->hasFile('image')) {

        $name = time().'.'.$request->file('image')->getClientOriginalName();

        $image = Image::make($request->file('image'))->resize(10, 10);

        $destinationPath = public_path('/images/members/'. $name);
     
        $image->save($destinationPath);
    }

    TeamMember::insert([
        'name' => $mem_name,
        'position' => $position,
        'skills' => $skills,
        'joined' => $joined,
        'image' => $destinationPath,
    ]);

Not usually a good idea to use the client original filename

Please or to participate in this conversation.