title: Saving files locally with Laravel
body: <p>I'm saving files locally in Laravel, however I'm having issues getting the right URL and accessing the files.</p>
  
  <p>I've setup a symlink with Artisan:</p>
  
  <pre><code>php artisan storage:link 
  </code></pre>
  
  <p>When saving, I add <code>public/</code> to the name, so the files are placed in the <code>/storage/app/public/</code> directory, which works.</p>
  
  <pre><code>if ($request-&gt;hasFile('files')) {
      $files = array();
  
      foreach ($request-&gt;file('files') as $file) {
          if ($file-&gt;isValid()) {
              $name = time() . str_random(5) . '.' . $file-&gt;getClientOriginalExtension();
              Storage::disk('public')-&gt;put($name, $file);
              $files[] = $name;
          }
      }
  
      if (count($files) &gt; 0) {
          $response-&gt;assets = json_encode($files);
      }
  }
  </code></pre>
  
  <p>The name is stored in the database</p>
  
  <pre><code>["1524042807kdvws.pdf"]
  </code></pre>
  
  <p>Then the assets are returned as part of a JSON object via my API for Vue</p>
  
  <pre><code>if (count($response-&gt;assets) &gt; 0) {
      $assets = array();
      foreach (json_decode($response-&gt;assets, true) as $asset) {
          $assets[] = asset($asset);
      }
      $responses[$key]-&gt;assets = $assets;
  }
  </code></pre>
  
  <p>Which returns <code>http://127.0.0.1:8000/1524042807kdvws.pdf</code> but that 404s. I've gotten myself a little confused I think, so any pointers or help would be appreciated.</p>