title: when the user upload a new image the previous image delete from folder laravel
body: <p>when the user upload new image i want to delete the previous image in folder i use Laravel....i try to make some things but not work for me any ideas?</p>
  
  <pre><code>$user = User::find(Auth::user()-&gt;id);
  File::delete($user-&gt;pic);
  </code></pre>
  
  <hr>
  
  <pre><code>#profileController
  &lt;?php
  namespace App\Http\Controllers;
  
  use Illuminate\Http\Request;
  use Illuminate\Support\Facades\Auth;
  use Illuminate\Support\Facades\DB;
  
  class ProfileController extends Controller
  {
      public function index($slug){
          return view('profile.index')-&gt;with('data', Auth::user()-&gt;profile);
      }
  
      public function uploadPhoto(Request $request) {
          $file = $request-&gt;file('pic');
          $filename = $file-&gt;getClientOriginalName();
          $path = 'storage/img';
  
          $file-&gt;move($path, $filename);
          $user_id = Auth::user()-&gt;id;
  
          DB::table('users')-&gt;where('id',$user_id)-&gt;update(['pic' =&gt;$filename]);
  
          return redirect('/editProfile')-&gt;withSuccess('Your image was successful.');
      }
  }
  </code></pre>