Checkout the docs. There you can find everything you need. https://laravel.com/docs/5.2/filesystem#retrieving-files
Aug 8, 2016
7
Level 4
How to get properties (name, size, type) of a file retrieved from storage
Hey,
I am retrieving a folder related to an event model which contains 3 or 4 files that are already stored.
@foreach (Storage::files($event->getDirectoryPath()) as $download)
<div class="row">
<div class="col-sm-6">
<p>Download Name</p>
</div>
<div class="col-sm-2">PDF</div>
<div class="col-sm-2">125k</div>
<div class="col-sm-2">
<a href="" class="btn btn-primary btn-block">Download</a>
</div>
</div>
@endforeach
How do i get the file name, size and type and eventually how do i let them download this file with a click of a button without redirecting.
at the moment $download just return the string of the file. (event_attachments/86_y01e6oqrl4n92mx/myimage.png)
When i create the file, would it be easier to store the name, size and type in the database because atm i am only storing the path?
Please or to participate in this conversation.