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

fedaaelmasri's avatar

laravel not show new image after editing only if remove cache

When I modify the images, the editing process succeeds, but no changes are made to the pictures and the new image does not appear after the edit except when I delete the cache.

$brands = Brands::findOrfail($id);

$image = $request->file('image');
    if ($image && $image->isValid()) {
        $path = $image->storeAs('brands', basename($brands->image),'public');
        $brands->image = $path;
    }

    $brands->name = $request->input('name');
    $brands->description =$description;

     if ($brands->save()) {
        return redirect(route('admin.brands'))->with([
            'message' => sprintf(' The Brand: "%s" edit success !', $brands->name),
            'alert-type' => 'success'
        ]);
    } else {
        return redirect()->back()->with([
            'message' => sprintf(' The Brand : "%s" can not edit success !', $brands->name),
            'alert-type' => 'error'
        ])->withInput();
    }
0 likes
4 replies
shariff's avatar

@fedaaelmasri can you make it code in format by placing ``` before and after the code so we can understand properly

Snapey's avatar

perhaps you could cache bust the image in the view

Suppose you insert the image in your view like

<img src='{{ $brands->image }}' >

You could force your browser to appreciate it has changed by adding the timestamp that the record was updated_at

<img src='{{ $brands->image . '?' . $brands->updated_at->format('U') }}' >
nafeeur10's avatar

@fedaaelmasri,

storeAs() is generally used when a file is already uploaded. So, it can create problem witih cache. You can use move()

$request->image->move(public_path('images/brands'), $imageName);

Please or to participate in this conversation.