Uploaded Files

Retrieve uploaded file from request

$file = $request->file('photo');
$file = $request->photo;

Get file path or extension

$path = $request->photo->path();
$extension = $request->photo->extension();

Store uploaded file with a randomly generated filename

// path where the file should be stored relative to
// the filesystem's configured root directory
$path = $request->photo->store('images'); 
// optional 2nd param to specify the filesystem disk
$path = $request->photo->store('images', 's3');

Store uploaded file and specify the name

$path = $request->photo->storeAs('images', 'filename.jpg');
$path = $request->photo->storeAs('images', 'filename.jpg', 's3');

See More: Laravel File Storage

Comments