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

henryoladj's avatar

Trying to save Uploaded Image with Name

On my Laravel Local Server this code works

private function storeImage($news)
    {
        if (request()->has('image')){
             $original = request()->file('image')->getClientOriginalName();

            $news->update([
                'image' =>  request()->file('image')->storeAs('uploads', $original),
            ]);

            $image = Image::make(public_path('image/'. $news->image))->resize(664, 373);
            $image->save();
        }
    }

But on my Shared Hosting Server it does not save the image or even the post into the database... Meanwhile making a post without images saves into the database

0 likes
2 replies
Sinnbeck's avatar

Do you get any sort of errors ? Check in laravel.log

Nakov's avatar

Just to add to this, do you have a folder called uploads on the shared hosting. Make sure that the directory is writable as well, maybe it fails to write.

From your method you also don't return anything else, so you won't know what is going on, and will just get a blank page.. At the very bottom return back with some message maybe.

1 like

Please or to participate in this conversation.