FileUtil provides basic support for file functionality like HTTP file upload.
- Author
- ingo herwig ingo@.nosp@m.wemo.nosp@m.ve.co.nosp@m.m
Definition at line 22 of file FileUtil.php.
|
static | uploadFile ($mediaFile, $destName, $mimeTypes=null, $override=true) |
|
static | getMimeType ($file) |
|
static | fputsUnicode ($fp, $str) |
|
static | getFiles ($directory, $pattern='/./', $prependDirectoryName=false, $recursive=false) |
|
static | getDirectories ($directory, $pattern='/./', $prependDirectoryName=false, $recursive=false) |
|
static | copyRec ($source, $dest) |
|
static | copyRecDir ($source, $dest) |
|
static | mkdirRec ($dirname, $perm=0775) |
|
static | emptyDir ($dirname) |
|
static | realpath ($path) |
|
static | sanitizeFilename ($file) |
|
static | fixFilename ($file) |
|
static | urlencodeFilename ($file) |
|
static | fileExists ($file) |
|
static | basename ($file) |
|
◆ uploadFile()
static uploadFile |
( |
|
$mediaFile, |
|
|
|
$destName, |
|
|
|
$mimeTypes = null , |
|
|
|
$override = true |
|
) |
| |
|
static |
Copy an uploaded file to a given destination (only if the mime type matches the given one).
- Parameters
-
$mediaFile | An associative array with the following keys: 'name', 'type', 'tmp_name' (typically a $_FILES entry) |
$destName | The destination file name |
$mimeTypes | An array holding the allowed mime types, null if arbitrary (default: null) |
$override | Boolean whether an existing file should be overridden, if false an unique id will be placed in the filename to prevent overriding (default: true) |
- Returns
- The filename of the uploaded file
Definition at line 32 of file FileUtil.php.
◆ getMimeType()
static getMimeType |
( |
|
$file | ) |
|
|
static |
Get the mime type of the given file.
- Parameters
-
- Returns
- String
Definition at line 66 of file FileUtil.php.
◆ fputsUnicode()
static fputsUnicode |
( |
|
$fp, |
|
|
|
$str |
|
) |
| |
|
static |
Write unicode to file.
- Parameters
-
$fp | File Handle |
$str | String to write |
Definition at line 86 of file FileUtil.php.
◆ getFiles()
static getFiles |
( |
|
$directory, |
|
|
|
$pattern = '/./' , |
|
|
|
$prependDirectoryName = false , |
|
|
|
$recursive = false |
|
) |
| |
|
static |
◆ getDirectories()
static getDirectories |
( |
|
$directory, |
|
|
|
$pattern = '/./' , |
|
|
|
$prependDirectoryName = false , |
|
|
|
$recursive = false |
|
) |
| |
|
static |
◆ copyRec()
static copyRec |
( |
|
$source, |
|
|
|
$dest |
|
) |
| |
|
static |
Recursive copy for files/directories.
- Parameters
-
$source | The name of the source directory/file |
$dest | The name of the destination directory/file |
Definition at line 179 of file FileUtil.php.
◆ copyRecDir()
static copyRecDir |
( |
|
$source, |
|
|
|
$dest |
|
) |
| |
|
static |
Recursive copy for directories.
- Parameters
-
$source | The name of the source directory |
$dest | The name of the destination directory |
Definition at line 196 of file FileUtil.php.
◆ mkdirRec()
static mkdirRec |
( |
|
$dirname, |
|
|
|
$perm = 0775 |
|
) |
| |
|
static |
Recursive directory creation.
- Parameters
-
$dirname | The name of the directory |
$perm | The permission for the new directories (default: 0775) |
Definition at line 215 of file FileUtil.php.
◆ emptyDir()
static emptyDir |
( |
|
$dirname | ) |
|
|
static |
Empty a directory.
- Parameters
-
$dirname | The name of the directory |
Definition at line 225 of file FileUtil.php.
◆ realpath()
◆ sanitizeFilename()
static sanitizeFilename |
( |
|
$file | ) |
|
|
static |
◆ fixFilename()
static fixFilename |
( |
|
$file | ) |
|
|
static |
Fix the name of an existing file to be used with php file functions.
- Parameters
-
- Returns
- String or null, if the file does not exist
Definition at line 286 of file FileUtil.php.
◆ urlencodeFilename()
static urlencodeFilename |
( |
|
$file | ) |
|
|
static |
Url encode a file path.
- Parameters
-
- Returns
- String
Definition at line 304 of file FileUtil.php.
◆ fileExists()
static fileExists |
( |
|
$file | ) |
|
|
static |
Check if the given file exists.
- Parameters
-
- Returns
- Boolean
Definition at line 318 of file FileUtil.php.
◆ basename()
Get the trailing name component of a path (locale independent)
- Parameters
-
- Returns
- String
Definition at line 327 of file FileUtil.php.