title: Laravel - Can't save files to public_path using storeAs
body: <p>I cannot upload files to the public_path folder in Laravel 5.4. I can't understand what's going wrong, <a href="https://laravel.com/docs/5.4/filesystem#file-uploads" rel="nofollow noreferrer">the documentation makes it look easy</a>. <code>$request</code> is the POSTed contents of a form. <code>filename</code> is a file submitted via the form.</p>
  
  <pre><code>public function uploadFile($request) {
  
      if ($request-&gt;hasFile('filename') &amp;&amp; $request-&gt;file('filename')-&gt;isValid()) {
          $file = $request-&gt;filename;
  
          $hash = uniqid(rand(10000,99999), true);
  
          $directory = public_path('files/'.$hash);
  
          if(File::makeDirectory($directory, 0775, true)) {
              return $file-&gt;storeAs($directory, $file-&gt;getClientOriginalName());
          }
      }
  
      return NULL;
  }
  </code></pre>
  
  <p>The directory is created, but there's no file inside. As you can see, the folder has 775 permissions.</p>
  
  <p>I've tried added a trailing slash. I've tried removing <code>public_path</code> altogether. Nothing works. </p>
  
  <p>What am I doing wrong? :(</p>