i want upload file in laravel, using local server , not cloud storage. doc,i found 2 methods related file upload,
- normal method
(request::file('file')->move(dest,filename)) - using file system
but not understand actual difference between these methods?
if using normal method,
$file->move('path', $filename); here should path located,storage/app or public/uploads(new)?
how can upload files using file system ?
the "normal" method allows save uploaded file in local filesystem in place choose, long php has write access location. method can used "save" operation , uploaded files.
the "filesystem" method more flexible adds layer of abstraction on place write to. filesystem configuration stored in separate config , transparent code. can change underlying storage (e.g. local cloud) or change paths without changes code. filesystem gives lot of additional helper methods operate on files store, list files, checking existence, removing. additional advantage can used files, not ones uploaded user during current request.
answering second question: decide store files in both normal , filesystem method. in normal method pass path, in filesystem configure paths using filesystems.php config.
and how upload file using file systems? don't use filesystem upload file, use save uploaded file. upload process same, instead of calling $uploadedfile->move() do:
storage::put('file key', file_get_contents(request::file('file')->getrealpath()));
Comments
Post a Comment