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

makerbiles6's avatar

Images not showing up in view!!

The images I save to a database table won't show up in my view. The images get saved in my DB as:

uploads/Ra3OPvFAK07Uki0k8H73EWpeSQx98B5dzzw9YrFC.jpeg

And the images get also stored in dir: storage/app/public/uploads

I reference the image in my view as:

src="{{ asset('/storage/' . $tweet->images[0]->image) }}" // the first image in a collection Then in the browser it shows up like this:

src="http://127.0.0.1:8000/storage/uploads/Ra3OPvFAK07Uki0k8H73EWpeSQx98B5dzzw9YrFC.jpeg"

Saving images:

public function store() { $attributes = request()->validate([ 'image' => [function($attribute, $value, $fail) { if(count($value) > 4) { return $fail('Max 4 files accepted!'); } }], 'image[]' => ['file', 'mimes:jpeg,png,jpg', 'size:10'], 'body' => ['required', 'min:1', 'max:255'] ]);

    $tweet = Tweet::create([ 
        'user_id' => auth()->id(),
        'body' => $attributes['body']
    ]);

   $tweet_id = $tweet->id; // Get the current tweets id from DB

    if(request('image')) { // For each image save a record in DB
        foreach(request('image') as $image) {
            Image::create([
                'user_id' => auth()->id(),
                'tweet_id' => $tweet_id,
                'image' => $image->store('uploads')
            ]);
        }
    } 

    return back();
}

https://shareit.onl/ https://appvn.onl/

0 likes
1 reply

Please or to participate in this conversation.