Skip to content

v2.4.0

Compare
Choose a tag to compare
@ibnsultan ibnsultan released this 09 Aug 19:15
· 25 commits to v2.x since this release
c14b208
  1. store Method:

    • 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 as max_file_size, file_type, and extensions.
    • Returns: An object containing status, path, and error message.
    • 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;
  1. storeAs Method:

    • 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 as max_file_size, file_type, and extensions.
    • Returns: An object containing status, path, and error message.
    • 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;