\Symfony\Component\HttpFoundation\FileFile

A file in the file system.

Summary

Methods
Properties
Constants
__construct()
guessExtension()
getMimeType()
move()
No public properties found
No constants found
getTargetFile()
getName()
No protected properties found
N/A
No private methods found
No private properties found
N/A

Methods

__construct()

__construct(string  $path, boolean  $checkPath = true) 

Constructs a new file from the given path.

Parameters

string $path

The path to the file

boolean $checkPath

Whether to check the path or not

Throws

\Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException

If the given path is not a file

guessExtension()

guessExtension() : string|null

Returns the extension based on the mime type.

If the mime type is unknown, returns null.

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

Returns

string|null —

The guessed extension or null if it cannot be guessed

getMimeType()

getMimeType() : string|null

Returns the mime type of the file.

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.

Returns

string|null —

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

move()

move(string  $directory, string  $name = null) : self

Moves the file to a new location.

Parameters

string $directory

The destination folder

string $name

The new file name

Throws

\Symfony\Component\HttpFoundation\File\Exception\FileException

if the target file could not be created

Returns

self —

A File object representing the new file

getTargetFile()

getTargetFile(  $directory,   $name = null) 

Parameters

$directory
$name

getName()

getName(string  $name) : string

Returns locale independent base name of the given path.

Parameters

string $name

The new file name

Returns

string —

containing