v2.4.0
-
storeMethod:- Purpose: This method stores a file from the request to a specified directory.
- Parameters:
string $key: The name of the file input in the request.string $destination: The directory where the file should be stored.array $configs: Optional configurations such asmax_file_size,file_type, andextensions.
- Returns: An object containing
status,path, anderrormessage. - Benefit: Allows for validating file extensions and size limits, providing more granular control over file uploads.
# without options
request::store('file', '/uploads/directory')
# with options
request::store('file', '/uploads/directory', [
'extensions' => 'extensions' => ['jpg', 'jpeg', 'png', 'gif']
]
// output: FsInstance::$uploadInfo;-
storeAsMethod:- Purpose: This method stores a file from the request with a specific name.
- Parameters:
string $key: The name of the file input in the request.string $destination: The directory where the file should be stored.string $filename: The name to give the stored file.array $configs: Optional configurations such asmax_file_size,file_type, andextensions.
- Returns: An object containing
status,path, anderrormessage. - Benefit: Provides the ability to rename files upon upload, in addition to validating extensions and size limits.
# without options
request::storeAs('file', '/uploads/directory', 'myNewName')
# with options
request::storeAs('file', '/uploads/directory', 'myNewName', [
'file_type' => 'image',
'max_file_size' => 10
]
// output: FsInstance::$uploadInfo;