title: How to prevent duplicate filenames in laravel?
body: <p>This is the code I have in a store method from one of my controllers.</p>
  
  <pre><code>    // Get the file object from the user input.
      $file = Request::file('filefield');
  
      // Get the filename by referring to the input object
      $fileName = $file-&gt;getClientOriginalName();
  
      if (!Storage::exists($fileName))
      {
          Storage::disk('local')-&gt;put($fileName, File::get($file));
      } else {
          return 'Hey this file exist already';
      }
  </code></pre>
  
  <p>It works fine but the problem that I had, is that it allowed for duplicate filenames and the file obviously wouldn't upload. I tried fixing it with this which is fine so far.</p>
  
  <p>Now I'm guessing if I want a user to upload a filename with an identical name to one that I already have I need to append something like a number to the filename.</p>
  
  <p>My question is what is the best way of going about this in laravel?</p>
  
  <p>Help is much appreciated.</p>