FileHelper
- Type
- Class
- Namespace
- Craft
- Inherits
- Craft\FileHelper » CFileHelper (opens new window)
- Since
- 2.5
Class FileHelper
See also http://craftcms.com
View source (opens new window)
# Public Methods
Method | Description |
---|---|
copyDirectory() (opens new window) | Copies a directory recursively as another. |
createDirectory() (opens new window) | Shared environment safe version of mkdir. Supports recursive creation. |
findFiles() (opens new window) | Returns the files found under the specified directory and subdirectories. |
getExtension() (opens new window) | Returns the extension name of a file path. |
getExtensionByMimeType() | Determines the file extension name based on a given MIME type, or a file path. |
getMimeType() (opens new window) | Determines the MIME type of the specified file. |
getMimeTypeByExtension() (opens new window) | Determines the MIME type based on the extension name of the specified file. |
removeDirectory() (opens new window) | Removes a directory recursively. |
# getExtensionByMimeType()
Determines the file extension name based on a given MIME type, or a file path. This method will use a local map between MIME type and extension name.
View source (opens new window)
Arguments
$file
(string (opens new window)) – The file name or mime type$magicFile
(string (opens new window)) – The path of the file that contains all available extension information. If this is not set, the default 'system.utils.fileExtensions' file will be used.
Returns
string (opens new window), null (opens new window) – The extension name. Null is returned if the extension cannot be determined.
Signature
public static string, null getExtensionByMimeType ( $file, $magicFile = null )
# Protected Methods
Method | Description |
---|---|
copyDirectoryRecursive() (opens new window) | Copies a directory. |
findFilesRecursive() (opens new window) | Returns the files found under the specified directory and subdirectories. |
validatePath() (opens new window) | Validates a file or directory. |