class File extends SplFileInfo
A file in the file system.
__construct(string $path, bool $checkPath = true) Constructs a new file from the given path. | ||
string|null | guessExtension() Returns the extension based on the mime type. | |
string|null | getMimeType() Returns the mime type of the file. | |
File | move(string $directory, string $name = null) Moves the file to a new location. | |
getTargetFile($directory, $name = null) | ||
string | getName(string $name) Returns locale independent base name of the given path. |
Constructs a new file from the given path.
string | $path | The path to the file |
bool | $checkPath | Whether to check the path or not |
FileNotFoundException | If the given path is not a file |
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.
string|null | The guessed extension or null if it cannot be guessed |
ExtensionGuesser | |
getMimeType() |
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.
string|null | The guessed mime type (e.g. "application/pdf") |
MimeTypeGuesser |
Moves the file to a new location.
string | $directory | The destination folder |
string | $name | The new file name |
File | A File object representing the new file |
FileException | if the target file could not be created |
$directory | ||
$name |
Returns locale independent base name of the given path.
string | $name | The new file name |
string | containing |
© 2004–2017 Fabien Potencier
Licensed under the MIT License.
https://api.symfony.com/4.1/Symfony/Component/HttpFoundation/File/File.html