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

Gintron's avatar

Slow Image Upload on server

Hy, I am storing images to website, on my local environment everything happens quickly, but on my web server (TMD hosting) it takes up to one minute to store the image:

This is my code:

private function storeImage($request){
        $image = $request->file('image');
        $input= time().$image->getClientOriginalName();
        $destinationPath = public_path('images');
        $img = Image::make($image->getRealPath());
        $img->resize(900, 675, function($constraint){
            $constraint->aspectRatio();
        })->save($destinationPath.'/'.$input, 70);

        return $input;
    }

For storing a job post

if($request->image){
                $input = $this->storeImage($request);
                $attributes['image'] = $input;
            }
 $request->user()->jobs()->create($attributes);

For editing a job post

if($request->image){
            File::delete(public_path('images/'.$job->image));
            $input = $this->storeImage($request);
            $job->image = $input;
        }

        $job->save();

Am I doing something wrong in the code or is the server just too slow?

0 likes
1 reply
jlrdw's avatar

Maybe live server there's a bandwidth issue (not sure), maybe you could used a queued job. Just suggestion.

Also check with host, do a ticket and ask about bandwidth and that sort of things. Just suggestions.

Also is it faster a direct upload without the resizing.

1 like

Please or to participate in this conversation.