Documentation

File extends File
in package
Uses FileHelpers

A file in the file system.

Table of Contents

$hashName  : string
The cache copy of the file's hash name.
__construct()  : mixed
Constructs a new file from the given path.
clientExtension()  : string
Get the file's extension supplied by the client.
extension()  : string
Get the file's extension.
getMimeType()  : string|null
Returns the mime type of the file.
guessExtension()  : string|null
Returns the extension based on the mime type.
hashName()  : string
Get a filename for the file.
move()  : self
Moves the file to a new location.
path()  : string
Get the fully qualified path to the file.
getName()  : string
Returns locale independent base name of the given path.
getTargetFile()  : mixed

Properties

$hashName

The cache copy of the file's hash name.

protected string $hashName = null

Methods

__construct()

Constructs a new file from the given path.

public __construct(string $path[, bool $checkPath = true ]) : mixed
Parameters
$path : string

The path to the file

$checkPath : bool = true

Whether to check the path or not

Tags
throws
FileNotFoundException

If the given path is not a file

Return values
mixed

clientExtension()

Get the file's extension supplied by the client.

public clientExtension() : string
Return values
string

extension()

Get the file's extension.

public extension() : string
Return values
string

getMimeType()

Returns the mime type of the file.

public getMimeType() : string|null

The mime type is guessed using a MimeTypeGuesser instance, which uses finfo(), mime_content_type() and the system binary "file" (in this order), depending on which of those are available.

Tags
see
MimeTypeGuesser
Return values
string|null

The guessed mime type (e.g. "application/pdf")

guessExtension()

Returns the extension based on the mime type.

public guessExtension() : string|null

If the mime type is unknown, returns null.

This method uses the mime type as guessed by getMimeType() to guess the file extension.

Tags
see
ExtensionGuesser
see
getMimeType()
Return values
string|null

The guessed extension or null if it cannot be guessed

hashName()

Get a filename for the file.

public hashName([string $path = null ]) : string
Parameters
$path : string = null
Return values
string

move()

Moves the file to a new location.

public move(string $directory[, string $name = null ]) : self
Parameters
$directory : string

The destination folder

$name : string = null

The new file name

Tags
throws
FileException

if the target file could not be created

Return values
self

A File object representing the new file

path()

Get the fully qualified path to the file.

public path() : string
Return values
string

getName()

Returns locale independent base name of the given path.

protected getName(string $name) : string
Parameters
$name : string

The new file name

Return values
string

containing

getTargetFile()

protected getTargetFile(mixed $directory[, mixed $name = null ]) : mixed
Parameters
$directory : mixed
$name : mixed = null
Return values
mixed

Search results