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

Syrine123's avatar

Why I get result:ok and then not found when I try to update picture with Cloudinary ?

Hello everyone, I'm trying to update picture with cloudinary. It was working correctly since one month but now when I try to test it I got AT first {result:"ok"} but the message should be : Media successfully updated! and when I try to update it another time I got : " not found" I didn't know what's the issue behind this error. The pictures are stored in a folder named Testing in Cloudinary Actually I'm no longer having time to resolve this issue because tomorrow I have to expose my project for my graduation. this is the code:

public function updatePicture(Request $request, $user_id){

    $image_details= User::select('public_id', 'user_image')->where('user_id',$user_id)->first();
    $user_image=$image_details->user_image;
    $user_image_split = explode('/', $user_image);
    
    $image_id = explode('.', $user_image_split[sizeof($user_image_split)-1]);
    
    if ($image_id != null) {
                
                try { 
            
                   return Cloudinary::destroy('Testing/'.$image_id[0]);
                    
                     } catch (\Exception $e) { 
                    return $e->getMessage();
                     }
                     return 'not deleted';
    
                }
                $new_user_image = Cloudinary::upload(
                    $request->file('user_image')->getRealPath(),
                    [
                        'folder' => 'Testing'
                    ]
                )->getSecurePath();
                $user = User::find($user_id);
                $user->public_id = $image_id;
                $user->user_image = $new_user_image;
                $user->update();
                return back()->with('success_msg', 'Media successfully updated!');
    
    }
    

Your answers will save my final school year. Thanks in advance for your suggestions

0 likes
5 replies
bobwurtz's avatar

If you haven't changed any of your code and it was previously working then the issue could be from Cloudinary. I've never used it before, but their website says that each tier of service comes with a certain number of monthly credits. Could you be out of credits?

Syrine123's avatar

@bobwurtz I'm using free account. Even wHEN I created new account I got the same error

Sinnbeck's avatar

Where exactly are you getting {result:"ok"}. i feel some information is missing?

Sinnbeck's avatar

@Syrine123 does the image update on cloudinary? Try adding a dd('hit'); to the top of the method and see if it triggers

Please or to participate in this conversation.