| Fully Qualified Name: | CodeIgniter\Files\File |
| Extends: | SplFileInfo |
Wrapper for PHP's built-in SplFileInfo, with goodies.
| Name | Description | Defined By |
|---|---|---|
| __construct() | Run our SplFileInfo constructor with an optional verification that the path is really a file. | File |
| getDestination() | Returns the destination path for the move operation where overwriting is not expected. | File |
| getMimeType() | Retrieve the media type of the file. SHOULD not use information from the $_FILES array, but should use other methods to more accurately determine the type of file, like finfo, or mime_content_type(). | File |
| getRandomName() | Generates a random names based on a simple hash and the time, with the correct file extension attached. | File |
| getSize() | Retrieve the file size. | File |
| getSizeByUnit() | Retrieve the file size by unit. | File |
| guessExtension() | Attempts to determine the file extension based on the trusted getType() method. If the mime type is unknown, will return null. | File |
| move() | Moves a file to a new location. | File |
Run our SplFileInfo constructor with an optional verification that the path is really a file.
| Parameter Name | Type | Description |
|---|---|---|
| $path | string | |
| $checkFile | bool |
Returns:
Returns the destination path for the move operation where overwriting is not expected.
First, it checks whether the delimiter is present in the filename, if it is, then it checks whether the last element is an integer as there may be cases that the delimiter may be present in the filename. For the all other cases, it appends an integer starting from zero before the file's extension.
| Parameter Name | Type | Description |
|---|---|---|
| $destination | string | |
| $delimiter | string | |
| $i | int |
Returns: string
Retrieve the media type of the file. SHOULD not use information from the $_FILES array, but should use other methods to more accurately determine the type of file, like finfo, or mime_content_type().
Returns: string|null The media type we determined it to be.
Generates a random names based on a simple hash and the time, with the correct file extension attached.
Returns: string
Retrieve the file size.
Implementations SHOULD return the value stored in the "size" key of the file in the $_FILES array if available, as PHP calculates this based on the actual size transmitted.
Returns: int The file size in bytes
Retrieve the file size by unit.
| Parameter Name | Type | Description |
|---|---|---|
| $unit | string |
Returns: int|string
Attempts to determine the file extension based on the trusted getType() method. If the mime type is unknown, will return null.
Returns: string|null
Moves a file to a new location.
| Parameter Name | Type | Description |
|---|---|---|
| $targetPath | string | |
| $name | string|null | |
| $overwrite | bool |
Returns: \CodeIgniter\Files\File