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
Post a Comment