Detailed Description

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 Public Member Functions

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 fileExists ($file)
 

Member Function Documentation

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
$mediaFileAn associative array with the following keys: 'name', 'type', 'tmp_name' (typically a $_FILES entry)
$destNameThe destination file name
$mimeTypesAn array holding the allowed mime types, null if arbitrary (default: null)
$overrideBoolean 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.

static getMimeType (   $file)
static

Get the mime type of the given file.

Parameters
$fileThe file
Returns
String

Definition at line 67 of file FileUtil.php.

static fputsUnicode (   $fp,
  $str 
)
static

Write unicode to file.

Parameters
$fpFile Handle
$strString to write

Definition at line 87 of file FileUtil.php.

static getFiles (   $directory,
  $pattern = '/./',
  $prependDirectoryName = false,
  $recursive = false 
)
static

Definition at line 99 of file FileUtil.php.

static getDirectories (   $directory,
  $pattern = '/./',
  $prependDirectoryName = false,
  $recursive = false 
)
static

Definition at line 139 of file FileUtil.php.

static copyRec (   $source,
  $dest 
)
static

Recursive copy for files/directories.

Parameters
$sourceThe name of the source directory/file
$destThe name of the destination directory/file

Definition at line 180 of file FileUtil.php.

static copyRecDir (   $source,
  $dest 
)
static

Recursive copy for directories.

Parameters
$sourceThe name of the source directory
$destThe name of the destination directory

Definition at line 197 of file FileUtil.php.

static mkdirRec (   $dirname,
  $perm = 0775 
)
static

Recursive directory creation.

Parameters
$dirnameThe name of the directory
$permThe permission for the new directories (default: 0775)

Definition at line 216 of file FileUtil.php.

static emptyDir (   $dirname)
static

Empty a directory.

Parameters
$dirnameThe name of the directory

Definition at line 226 of file FileUtil.php.

static realpath (   $path)
static

Realpath function that also works for non existing paths code from http://www.php.net/manual/en/function.realpath.php.

Parameters
$path
Returns
String

Definition at line 245 of file FileUtil.php.

static sanitizeFilename (   $file)
static

Get a sanitized filename code from: http://stackoverflow.com/questions/2021624/string-sanitizer-for-filename#2021729.

Parameters
$file
Returns
String

Definition at line 276 of file FileUtil.php.

static fixFilename (   $file)
static

Fix the name of an existing file to be used with php file functions.

Parameters
$file
Returns
String or null, if the file does not exist

Definition at line 287 of file FileUtil.php.

static fileExists (   $file)
static

Check if the given file exists.

Parameters
$file
Returns
Boolean

Definition at line 305 of file FileUtil.php.