php - laravel store files and access them -


i store files using code:

 $files = $request->file('files');     if($request->hasfile('files'))     {         foreach($files $file)         {             $file->store('files'));         }     } 

the files in example saved under storage/app/files/, fine since not publicly accessible (which neither supposed to). however, if want provide users download option of these files, how access them? thought of php reading file , 'render' user. however, i'm new laravel , bit lost @ point.

any ideas?

there's 3 main ways send files responses:

file download (uses content disposition: attachment)

return response()->download(storage_path("app/files/filename.ext")); //where filename.ext file want send 

inline file (uses content disposition: inline)

return response()->file(storage_path("app/files/filename.ext")); 

there's falling symfony's streamed response large files.


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -