FileHelper

Type
Class
Namespace
Craft
Inherits
Craft\FileHelper » CFileHelper
Since
2.5

Class FileHelper

See also http://craftcms.com

View source

Public Methods

MethodDescription
copyDirectory()Copies a directory recursively as another.
createDirectory()Shared environment safe version of mkdir. Supports recursive creation.
findFiles()Returns the files found under the specified directory and subdirectories.
getExtension()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()Determines the MIME type of the specified file.
getMimeTypeByExtension()Determines the MIME type based on the extension name of the specified file.
removeDirectory()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

Arguments

  • $file (string) – The file name or mime type
  • $magicFile (string) – 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, null – The extension name. Null is returned if the extension cannot be determined.

Signature

public static string, null getExtensionByMimeType ( $file, $magicFile = null )

Protected Methods

MethodDescription
copyDirectoryRecursive()Copies a directory.
findFilesRecursive()Returns the files found under the specified directory and subdirectories.
validatePath()Validates a file or directory.