Search
 
SCRIPT & CODE EXAMPLE
 

PHP

delete previous uploaded image when update laravel

        if($request->file('image'))
        {
            //to delete the prevous uploaded image
            @unlink(public_path('backend/uploads/profile/'.$user->image));
            //make the image name. here we are making name with current time
            $imageName = time().'.'.$request->image->extension();
            //time to upload to directroy you choose
            $request->image->move(public_path('backend/uploads/profile'), $imageName);
            //now save the image name to database
            $user['image'] = $imageName;
        }
        //finally time to save all things to database
        $user->save();
Comment

PREVIOUS NEXT
Code Example
Php :: how to add javascript in php 
Php :: laravel wherenotin 
Php :: wordpress get user profile picture 
Php :: laravel storage 
Php :: laravel form request validation unique update 
Php :: codeigniter 4 query builder get inserted id 
Php :: php trim quotes 
Php :: count an array in php 
Php :: laravel 8 blade get days and hours ago 
Php :: create a custom method laravel model 
Php :: laravel custom validation exception 
Php :: bootstrap pagination laravel 
Php :: why does php syntax doesnt work in my html 
Php :: wordpress get id from page title 
Php :: upload multiple files in codeigniter 
Php :: php code for video upload 
Php :: check if string contains only whitespace php 
Php :: How to disable Gutenberg / block editor for certain post types 
Php :: php full form 
Php :: php artisan route cache 
Php :: php get data from url 
Php :: php online editor 
Php :: end foreach loop 
Php :: Laravel Eloquent Query Using WHERE with OR AND OR? 
Php :: codeigniter installation with composer 
Php :: how to add page link in laravel 
Php :: how to get http parameters in php 
Php :: grouping routes based on controller laravel 
Php :: Eloquent models events 
Php :: basename in php 
ADD CONTENT
Topic
Content
Source link
Name
5+9 =